Answer the question
In order to leave comments, you need to log in
PHP - Vk Api - Photo upload - Where is the error?
Good day!
<?php
$token = 'TOKEN';
$data = array(
'album_id' => '195826674',
'access_token' => $token
);
$content = file_get_contents(' https://api.vkontakte.ru/method/photos.getUploadServer? '.http_build_query($data));
echo $content;
$json = json_decode($content, true);
$b = 'r4.jpg';
$url = $json['response']['upload_url'];;
$postData['file1'] = '@' . $b;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
curl_close($ch);
$res = json_decode($response);
$server = $res->{'server'};
$photo = $res->{'photos_list'};
$id = $res->{'photo'};
$hash = $res->{'hash'};
$aid = $res->{'aid'};
$gid = $res->{'gid'};
$data = array(
'server' => $server,
'aid' => $aid,
'gid' => $gid,
'hash' => $hash,
'photos_list' => $photo,
'access_token' => $token,
);
$page = file_get_contents(' https://api.vkontakte.ru/method/photos.save? '.http_build_query($data));
Writes:
Notice: Trying to get property of non-object in F:\xampp\htdocs\img\up.php on line 25
Notice: Trying to get property of non-object in F:\xampp\htdocs\img\up.php on line 26
Notice: Trying to get property of non-object in F:\xampp\htdocs\img\up.php on line 27
Notice: Trying to get property of non-object in F:\xampp\htdocs\img\up. php on line 28
Notice: Trying to get property of non-object in F:\xampp\htdocs\img\up.php on line 29
What's wrong?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question