簡體   English   中英

執行多個cURL請求

[英]Executing multiple cURL requests

我試圖順序執行多個curl請求,但我真的沒有運氣,這是我的代碼到目前為止,

//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提前!

嘗試使用curl_close
嘗試為兩個請求使用相同的curl資源
檢查是否為真,沒有任何請求發送到服務器

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM