2010-06-29 146 views
3

我想按顺序执行多个卷曲的要求,但我不是真的有运气好的话,这里是我的代码迄今,执行多个卷曲请求

//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.facebook.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); 

这个文件被调用,然后将两个请求应一个接一个地执行,但现在它只是不工作。

Thanx提前!

+0

我建议你使用Facebook的PHP SDK HTTP: //github.com/facebook/php-sdk/ – Codler 2010-06-29 11:28:04

+0

我已经得到它与上面的代码单独上传,但只要我把它在一个文件中,它打破了,所以我需要找到正确的方式来执行多个卷曲请求。 – Odyss3us 2010-06-29 11:43:33

回答

0

尝试使用curl_close
尝试使用相同的卷曲资源,两个请求
检查,如果是真的,那没有请求被发送到服务器