Created
December 13, 2022 13:46
-
-
Save Archie22is/fcc9d93f1bd1bffc0b3675451e21157f to your computer and use it in GitHub Desktop.
Php CURL Test
This file contains hidden or 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 | |
///////////////////// TESTING VARS | |
//$endpoint = 'https://dev.admin.englishwoodlandstimber.co.uk/api/sale/stock-list'; | |
//$secred = '46a4632d3d68173d2bea3dc684f82e70604704bf08817d6cb2fe959ca07768d8'; | |
$ch = curl_init($endpoint); | |
$headers = []; | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
// this function is called by curl for each header received | |
curl_setopt($ch, CURLOPT_HEADERFUNCTION, | |
function($curl, $header) use (&$headers) | |
{ | |
$len = strlen($header); | |
$header = explode(':', $header, 2); | |
if (count($header) < 2) // ignore invalid headers | |
return $len; | |
$headers[strtolower(trim($header[0]))][] = trim($header[1]); | |
return $len; | |
} | |
); | |
$data = curl_exec($ch); | |
print_r($headers); | |
///////////////////// TESTING |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment