0
我試圖實現一些多個捲曲函數,而不是簡單的捲曲函數。將腳本從cURL重建爲多個捲曲
我有下面的代碼片段:
$curl = curl_init();
curl_setopt($curl, CURLOPT_ENCODING,'gzip');
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_URL, $url);
$result = curl_exec($curl);
curl_close($curl);
$rv = ($returnArray) ? json_decode($result, true) : json_decode($result);
它給我的結果($結果回報的成功和一些數據)。我想重寫它以使用curl_multi_init()。我試過這個:
$curl = curl_init();
curl_setopt($curl, CURLOPT_ENCODING,'gzip');
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_URL, $url);
$mh = curl_multi_init();
curl_multi_add_handle($mh,$curl);
$running= \null;
do {
curl_multi_exec($mh,$running);
$result = curl_multi_exec($mh,$running);
} while($running > 0);
curl_multi_remove_handle($mh, $curl);
curl_multi_close($mh);
$rv = ($returnArray) ? json_decode($result, true) : json_decode($result);
我得不到結果($ result爲空)。我沒有任何錯誤。哪裏不對?
RTM:http://php.net/manual/en/function.curl-multi-exec.php - 'curl_multi_exec()'返回'INT '不是結果數組 – AeroX 2014-10-29 14:11:19