Answer the question
In order to leave comments, you need to log in
Why doesn't uploading photos via VK API work if I use cron?
Faced such a problem, I'm uploading photos to the VK album, via api.
So when you run the script via a direct link through the browser, everything works fine, the photos are loaded, I put it on cron and everything does not load photos_list returns empty.
Here is the code, can anyone tell me what the problem is
$imge = "/images/55391447-13.jpg";
$image_path = dirname(__FILE__).$imge;
$post_data = array("file1" => '@'.$image_path);
// получаем урл для загрузки
$url = file_get_contents("https://api.vk.com/method/photos.getUploadServer?album_id=".$album_id."&group_id=".$group."&v=".$v."&access_token=".$token);
$url = json_decode($url)->response->upload_url;
print_r($url);
// отправка post картинки
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$resultx = json_decode(curl_exec($ch),true);
//print_r($resultx);
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