Source :
$token = $authorization;
$headers = array(
'Authorization: Bearer ' . $token,
'Content-Type: application/json', // Adjust the content type as needed
);
function curl_apicall_get($curlurl,$headers)
{
$url = $curlurl;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // Follow the redirects automatically
curl_setopt($ch, CURLOPT_MAXREDIRS, 10); // Maximum number of redirects to follow
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpCode == 200) {
// Request successful, handle the response
//echo $response;
} else {
// Request failed, handle the error
echo "Error: HTTP Status Code $httpCode";
}
curl_close($ch);
return $response;
}
No comments:
Post a Comment