简体   繁体   中英

php retrieve curl_setopt POSTFIELDS string

Is there any way to retrieve the curl_setopt POSTFIELDS string which I had posted to the site after the curl_multi_exec($mh, $running) command?

Thanks.

You have to keep that data together with the individual resources:

$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,
    );
}

This keeps the cURL handles and data together in a single structure that you can later use to inspect.

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']);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM