php检索curl_setopt POSTFIELDS字符串

时间:2012-11-28 09:00:55

标签: php curl libcurl

有没有办法检索curl_multi_exec($ mh,$ running)命令后发布到网站的curl_setopt POSTFIELDS字符串?

感谢。

1 个答案:

答案 0 :(得分:0)

您必须将这些数据与各个资源一起保存:

$handles = array();
foreach ($urls as $url) {
    $ch = curl_init($url);
    $data = 'whatever';
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

    $handles[$url] = array(
        'ch' => $ch,
        'data' => $data,
    );
}

这会将cURL句柄和数据保存在一个结构中,以后可以用来检查。

foreach($handles as $url => $data) {
    // $url is the page you requested for this particular handle
    // $data['data'] contains the data that goes with it
    $body = curl_multi_getcontent($data['ch']);
    curl_multi_remove_handle($mh, $data['ch']);
    curl_close($data['ch']);
}