2010-06-29 143 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
嘗試使用相同的捲曲資源,兩個請求
檢查,如果是真的,那沒有請求被髮送到服務器