Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP - Display cURL Verbose info

Tags:

php

curl

stderr

I'm having some trouble with a particular cURL command and I'd like to see the headers and responses. In the command line I use -v and it displays everything, however...

In PHP I'm attempting to use:

curl_setopt($curl, CURLOPT_VERBOSE, 1);

However, nothing is being displayed.

I'm using PHP 5.3.24 on Windows Server 2008 on IIS.

Supposedly the info is sent into the stderr stream which I assume means the regular log used for PHP errors - however nothing is going there either. I'm getting no header results for cURL commands that I know are working and those that I know are not working.

like image 988
user2029890 Avatar asked Dec 05 '13 20:12

user2029890


People also ask

How do I know if my cURL is working in PHP?

php // Script to test if the CURL extension is installed on this server // Define function to test function _is_curl_installed() { if (in_array ('curl', get_loaded_extensions())) { return true; } else { return false; } } // Ouput text to user based on test if (_is_curl_installed()) { echo "cURL is <span style=\"color: ...


1 Answers

My guess is that you need to also return the buffer. This code works under Linux and might work for you under Win2008:

$browser = curl_init();
curl_setopt($browser, CURLOPT_URL, $url);
curl_setopt($browser, CURLOPT_RETURNTRANSFER, true);
curl_setopt($browser, CURLOPT_VERBOSE, true);
$data = curl_exec($browser);
echo $data;
like image 137
user984869 Avatar answered Oct 15 '22 02:10

user984869