Advertisement
drculun

php curl verbose example

Dec 18th, 2022 (edited)
13
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.99 KB | None | 0 0
  1. <?php $curl = curl_init();
  2. $streamVerboseHandle = fopen('php://temp', 'w+');
  3. curl_setopt_array($curl, array(
  4.   CURLOPT_URL => 'http://wa.jagojoki.id:3333/sessions/add',
  5.   CURLOPT_RETURNTRANSFER => true,
  6.   CURLOPT_ENCODING => '',
  7.   CURLOPT_MAXREDIRS => 10,
  8.   CURLOPT_TIMEOUT => 0,
  9.   CURLOPT_FOLLOWLOCATION => true,
  10.   CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  11.   CURLOPT_CUSTOMREQUEST => 'POST',
  12.   CURLOPT_POSTFIELDS => 'id=john&isLegacy=false',
  13.   CURLOPT_HTTPHEADER => array(
  14.     'Content-Type: application/x-www-form-urlencoded'
  15.   ),
  16.   CURLOPT_VERBOSE => true,
  17.   CURLOPT_STDERR => $streamVerboseHandle
  18. ));
  19. echo $response = curl_exec($curl); echo '<br/><br/>';
  20. if ($response === FALSE) { printf( "cUrl error (#%d): %s<br>\n", curl_errno($curl), htmlspecialchars( curl_error($curl) ) ); }
  21. rewind($streamVerboseHandle);
  22. $verboseLog = stream_get_contents($streamVerboseHandle);
  23. echo "cUrl verbose information:\n", "<pre>", htmlspecialchars($verboseLog), "</pre>\n";
  24. curl_close($curl); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement