D
D
dratsky2020-07-03 13:35:30
PHP
dratsky, 2020-07-03 13:35:30

How to change user photo via webhook?

I'm confused about writing a handler file that will edit the user from a third-party resource.
Problems with how to give him a file with a user photo.

$file=base64_encode(file("https://xxx/image"));
$data=http_build_query(
        [
            "ID"=>"38",
            "PERSONAL_PHOTO"=>$file
        ]
    );
$ch = curl_init('https://xxx.bitrix24.ru/rest/1/xxx/user.update');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response=curl_exec($ch);
curl_close($ch);
var_dump($response);

With such a recording, the user's photo does not change, but with Just the existing image flies. An attempt to set $file via file_get_contents either with base64 encryption or without it reacts as the wrong file type. In what form to set "PERSONAL_PHOTO" that this request transited?
$file=file("https://xxx/image");

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Tendor, 2020-07-03
@Tendor

Need to pass an array of photo data

$arr_file = array(
  "name" =>$_FILES['file']['name'],
  "size" =>$_FILES['file']['size'],
  "tmp_name" =>$_FILES['file']['tmp_name'],
  "type" => "",
  "old_file" => "",
  "del" => "Y",
  "MODULE_ID" => ""
);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question