trying to using an API which calling by an external link and basic token authorization.
it has 3 steps like :
1- asking for token ( every half an hour)
2- pass the token to another combo box to getting result by bearer token
3- passing same bearer token to another combo box for fetching data .
everything works fine (getting token from POSTMAN) but the problem is starting when requesting php curl calling straightforward in the codes which gives me : HTTP ERROR 500 (have to refresh token request every half an hour)
here is the code:
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.rasatpa.ir/auth/oauth/token',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array(,,),
CURLOPT_HTTPHEADER => array(
'Authorization: Basic YXRpeWVoSGNwV3M6QHRpeWUkd3NAdXNlcg=='
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
?>