Skip to content

Instantly share code, notes, and snippets.

@dars
Created August 26, 2013 19:31
Show Gist options
  • Save dars/6345609 to your computer and use it in GitHub Desktop.
Save dars/6345609 to your computer and use it in GitHub Desktop.
php curl debug
<?php
$verbose = fopen('php://temp', 'rw+');
$options = array(
CURLOPT_RETURNTRANSFER => 1, // 不直接印出結果
CURLOPT_URL => $target_url,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $query_string, //$data, // 直接給array
CURLOPT_VERBOSE => true,
CURLOPT_STDERR => $verbose
);
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
curl_close($ch);
!rewind($verbose);
$verboseLog = stream_get_contents($verbose);
echo '<pre>debug:';
var_dump($verboseLog);
echo $query_string."\n";
var_dump($result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment