CURL多输出到阵列

时间:2016-06-22 08:38:02

标签: php curl

我正在使用以下代码执行CURL Multi,它工作正常然后将结果输出到头部而不是我需要将结果放入数组中以便我可以处理它们,有没有人知道如何这样做?

$ch1 = curl_init();
$ch2 = curl_init();

$headr = array();
$headr[] = 'Authorization: Bearer xxxyyyzzz';

curl_setopt($ch1, CURLOPT_URL, "https:xxxyyyzzz");
curl_setopt($ch1, CURLOPT_HTTPHEADER, $headr);
curl_setopt($ch2, CURLOPT_URL, "https:xxxyyyzzz1");
curl_setopt($ch2, CURLOPT_HTTPHEADER, $headr);

//create the multiple cURL handle
$mh = curl_multi_init();

//add the two handles
curl_multi_add_handle($mh,$ch1);
curl_multi_add_handle($mh,$ch2);

$active = null;
//execute the handles
do { 
    $mrc = curl_multi_exec($mh, $active);
} 
    while ($mrc == CURLM_CALL_MULTI_PERFORM);
    while ($active && $mrc == CURLM_OK) {
    if (curl_multi_select($mh) != -1) {
        do {
            // Run the connections
            $mrc = curl_multi_exec($mh, $active);
        } while ($mrc == CURLM_CALL_MULTI_PERFORM);
    }
}
//close the handles
curl_multi_remove_handle($mh, $ch1);
curl_multi_remove_handle($mh, $ch2);
curl_multi_close($mh);

0 个答案:

没有答案