Answer the question
In order to leave comments, you need to log in
Malformed error when uploading photos to VK via curl?
I save the picture to the server with the name image.jpg, then I upload them to VK. Some images load without problems, and for some, the curl gives the following error: malformed.
function curl($url){
$aPost = array('file1' => new CURLFile("image.jpg"));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $aPost);
$res = curl_exec($ch);
echo curl_error($ch);
return $res;
}
https://ae01.alicdn.com/kf/HTB1rs9rKpXXXXb8XVXXq6x...
https://ae01.alicdn.com/kf/HTB1JwBfOpXXXXapXFXXq6x...
Answer the question
In order to leave comments, you need to log in
the VK API has a limit - 3 requests per second (any). Maybe the problem is that you make a lot of requests? (get a token, then immediately get a server for uploading images, upload image 1, upload image 2, save) - and all this is done in 1 second? And because of this, when requesting (4 requests per second) to get the server address for downloading images - an empty link is returned?
ps if the album and / or group does not change (where to post) - it is unnecessary to call the receive method before each picture (get the server address for downloading) - you can use the old one (when sending several pictures) (pss in my opinion now in a new way no more than 5 pictures at a time....) In any case, there should be no more than 3 requests per second when using the VK API. (I made my application not in php, of course, but in c#, and before each image loading, I put a "pause" for 450 milliseconds. The
problem is$url
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question