When using the PHP curl functions, is there anyway to see the exact raw headers that curl is sending to the server?
We can use curl -v or curl -verbose to display the request headers and response headers in the cURL command. The > lines are request headers .
Just use the below piece of code to get the response from restful web service url, I use social mention url. Oldie bug a goodie... +1 for using curl_setopt_array(). So much cleaner than calling curl_setopt() over and over.
cURL is a PHP extension that allows you to use the URL syntax to receive and submit data. cURL makes it simple to connect between various websites and domains.
There is a simple solution built into cURL if you are only interested in the response headers and not the content of the body. By setting the CURLOPT_HEADER and CURLOPT_NOBODY options to true, the result of curl_exec() will only contain the headers.
You can use curl_getinfo:
Before the call
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
After
$headers = curl_getinfo($ch, CURLINFO_HEADER_OUT);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With