Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@hubgit
Created December 2, 2011 16:40
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save hubgit/1423886 to your computer and use it in GitHub Desktop.
Save hubgit/1423886 to your computer and use it in GitHub Desktop.
Verbose cURL in PHP
<?php
// Request URL
$url = 'http://www.google.com/';
// HTTP headers
$headers = array(
//'Content-Type: application/json',
//'Accept: application/json',
);
// Content to send. If a Content-Type header is not specified when sent as POST data, the Content-Type will be set to 'application/x-www-form-urlencoded' and this should be an array; otherwise it can be a string.
//$content = json_encode($documents);
$curl = curl_init($url);
curl_setopt_array($curl, array(
CURLOPT_HTTPHEADER => $headers,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_VERBOSE => true,
//CURLOPT_POSTFIELDS => $content, // sets the method to POST automatically
));
$response = curl_exec($curl);
print_r($response);
//print_r(json_decode($response));
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
print_r($code);
@RulerOf
Copy link

RulerOf commented May 15, 2018

This snippet has been really helpful lately as I've been producing evidence of TLS 1.2 compatibility and CA support of some legacy stuff. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment