Created
March 24, 2023 01:09
-
-
Save petrusnog/db8bcfd672ae7fb17fb575685fcac611 to your computer and use it in GitHub Desktop.
Gets PHP cURL requisition logs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$curlHandle = curl_init(); | |
$curl_setopt_array = [ | |
CURLOPT_URL => 'https://google.com.br', | |
CURLOPT_RETURNTRANSFER => true, | |
CURLOPT_ENCODING => "", | |
CURLOPT_MAXREDIRS => 10, | |
CURLOPT_TIMEOUT => 0, | |
CURLOPT_FOLLOWLOCATION => true, | |
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, | |
CURLOPT_CUSTOMREQUEST => 'GET' | |
]; | |
curl_setopt_array($curlHandle, $curl_setopt_array); | |
// CURLOPT_VERBOSE: TRUE to output verbose information. | |
// Writes output to STDERR, | |
// -or- the file specified using CURLOPT_STDERR. | |
curl_setopt($curlHandle, CURLOPT_VERBOSE, true); | |
$streamVerboseHandle = fopen('php://temp', 'w+'); | |
curl_setopt($curlHandle, CURLOPT_STDERR, $streamVerboseHandle); | |
$result = curl_exec($curlHandle); | |
if ($result === FALSE) { | |
printf("cUrl error (#%d): %s<br>\n", | |
curl_errno($curlHandle), | |
htmlspecialchars(curl_error($curlHandle))) | |
; | |
} | |
rewind($streamVerboseHandle); | |
$verboseLog = stream_get_contents($streamVerboseHandle); | |
echo "cUrl verbose information:\n", | |
"<pre>", htmlspecialchars($verboseLog), "</pre>\n"; | |
die; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment