server json_decode vk photos getMessagesUploadSer ver true url server

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
$server = json_decode(vk("photos.getMessagesUploadServer", ""), true);
$url = $server["response"]["upload_url"];
if($curl = curl_init()){
curl_setopt($curl,CURLOPT_URL,$url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, array(
"photo" => "@".$name
));
$out = curl_exec($curl);
curl_close($curl);
}
$query = json_decode($out, true);
$up = json_decode(vk("photos.saveMessagesPhoto", array(
"server" => $query["server"],
"photo" => $query["photo"],
"hash" => $query["hash"]
)), true);
send($chat_id, $q, $up["response"][0]["id"]);