What Steps do you Take to Troubleshoot Problems with PHP cURL?

后端 未结 2 1576
误落风尘
误落风尘 2021-02-02 00:11

Almost any working PHP programmer has faced having to use CURL to send raw HTTP requests, whether it\'s for credit card payment processing, nefarious screen scraping, or somethi

2条回答
  •  悲哀的现实
    2021-02-02 00:42

    I find the CURLINFO_HEADER_OUT option to be very useful.

    request headers
      
    ', htmlspecialchars(curl_getinfo($curl, CURLINFO_HEADER_OUT)), '
    '; echo '
    response
    ', htmlspecialchars(dbg_curl_data(null)), '
    '; function dbg_curl_data($curl, $data=null) { static $buffer = ''; if ( is_null($curl) ) { $r = $buffer; $buffer = ''; return $r; } else { $buffer .= $data; return strlen($data); } }

提交回复
热议问题