Skip to content

Instantly share code, notes, and snippets.

@nextend
Last active June 15, 2018 11:38
Show Gist options
  • Save nextend/d53b677786821483843e413f374c3881 to your computer and use it in GitHub Desktop.
Save nextend/d53b677786821483843e413f374c3881 to your computer and use it in GitHub Desktop.
Curl verbose Facebook api test
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://graph.facebook.com/v2.12/oauth/access_token");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "postvar1=value1&postvar2=value2&postvar3=value3");
curl_setopt($ch, CURLOPT_VERBOSE, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$verbose = fopen('php://temp', 'w+');
curl_setopt($ch, CURLOPT_STDERR, $verbose);
$server_output = curl_exec($ch);
rewind($verbose);
$verboseLog = stream_get_contents($verbose);
echo "<pre>";
var_dump($server_output);
echo "Verbose information:\n<pre>", htmlspecialchars($verboseLog), "</pre>\n";
curl_close($ch);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment