I am trying to sequentially execute multiple curl requests, but I am not really having any luck, here is my code thus far,
//upload photo
$file= 'photo.jpg';
$args = array(
'message' => 'Photo from application',
);
$args[basename($file)] = '@' . realpath($file);
$ch = curl_init();
$url = 'https://graph.facebook.com/me/photos?access_token='.$token;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $args);
$data = curl_exec($ch);
$args_two = array(
'message' => 'This is a test post',
);
$ch_two = curl_init();
$url_two = 'https://graph.faceb开发者_Python百科ook.com/me/feed?access_token='.$token;
curl_setopt($ch_two, CURLOPT_URL, $url_two);
curl_setopt($ch_two, CURLOPT_HEADER, false);
curl_setopt($ch_two, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch_two, CURLOPT_POST, true);
curl_setopt($ch_two, CURLOPT_POSTFIELDS, $args_two);
$data_two = curl_exec($ch_two);
This file gets called and then the two requests should be executed one after the other, but right now it's just not working.
Thanx in advance!
Try to use curl_close
Try to use the same curl resource for two requests
Check if is it true, that none of requests is send to servers
精彩评论