See what CURL sends with PHP script

I have problems requesting a web form using CURL with a PHP script. I suspect that I am posting what the web server does not like. To see what CURL really sends, I would like to see all the message that is sent to the web server.

How can I configure CURL to give me full output?

I did

curl_setopt($ch, CURLOPT_VERBOSE, TRUE);

but this onal gives me part of the title. The content of the message is not displayed.

+5
source share
4 answers

Thanks for answers! In the end, they say that this is impossible. I went down the road and met Wireshark . Not an easy task, but definitely worth the effort.

+3
source

Have you tried CURLINFO_HEADER_OUT?

PHP curl_getinfo:

CURLINFO_HEADER_OUT - . , CURLINFO_HEADER_OUT , curl_setopt()

+1

If you want content, can't you just register it? I am doing something similar for API calls

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, self::$apiURL);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, count($dataArray));
curl_setopt($ch, CURLOPT_POSTFIELDS, $dataString);

$logger->info("Sending " . $dataString);
self::$results = curl_exec($ch);
curl_close($ch);

$decoded = json_decode(self::$results);
$logger->debug("Received " . serialize($decoded));

Or try

curl_setopt($ch, CURLOPT_STDERR, $fp);
-1
source

I would recommend using curl_getinfo .

<?php 
curl_exec($ch); 
   $info = curl_getinfo($ch); 
       if ( !empty($info) && is_array($info) { 
          print_r( $info ); 
          } else { 
                  throw new Exception('Curl Info is empty or not an array');
       };
 ?>
-2
source

All Articles