I'm trying to request an access token using a PHP script. I'm using curl to post my API key and secret and expecting to receive a JSON response which includes an access token. I'm failing (I don't get a response). Am I missing something in my code? I would have prefered to use an SDK but Amadeus does not have one for php.
$url = ' https://test.api.amadeus.com/v1/security/oauth2/token';
$curls = curl_init();
curl_setopt($curls, CURLOPT_URL, $url);
curl_setopt($curls, CURLOPT_RETURNTRANSFER, FALSE);
curl_setopt($curls, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($curls, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curls, CURLOPT_POST, true);
curl_setopt($curls, CURLOPT_POSTFIELDS, 'grant_type=client_credentials&client_id={id number}&client_secret={secret}');
curl_setopt($curls, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
$token = curl_exec($curls);
curl_close($curls);
print_r ($token);
curl_getinfo()
is your friend. – Alex HowanskyCURLOPT_POSTFIELDS
dont require to be json_encoded – tphobe9312curl_error($curls)
should tell you what went wrong – delboy1978uk