How to get info on sent PHP curl request

前端 未结 4 1941
故里飘歌
故里飘歌 2020-12-05 04:22

I\'m trying to debug a curl request to a webservice \'getToken\' endpoint.

I\'m not 100% confident that the URL and the auth info is getting written in to the curl

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-05 04:31

    The request is printed in a request.txt with details

    $ch = curl_init();
    $f = fopen('request.txt', 'w');
    curl_setopt_array($ch, array(
    CURLOPT_URL            => $url, 
    CURLOPT_RETURNTRANSFER => 1,
    CURLOPT_FOLLOWLOCATION => 1,
    CURLOPT_VERBOSE        => 1,
    CURLOPT_STDERR         => $f,
    ));
    $response = curl_exec($ch);
    fclose($f);
    curl_close($ch);
    

    You can also use curl_getinfo() function.

提交回复
热议问题