[API][Curl][Amadeus] Connexion a une api en php
Bonjour,
J'aimerais utiliser une api qui provient d'amadeus et pour se faire il me faut récupérer un token, j'ai donc fait ce bout de code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13
| $data = array(
'grant_type' => 'client_credentials',
'client_id' => '{Id_Key}',
'client_secret' => '{Secret_Key}');
$curls = curl_init();
curl_setopt($curls, CURLOPT_URL, 'https://test.api.amadeus.com/v1/security/oauth2/token');
curl_setopt($curls, CURLOPT_POST, true);
curl_setopt($curls, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($curls, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
$token = curl_exec($curls);
curl_close($curls);
print_r($token); |
Mais il ne me renvoie rien... J'ai donc essayé dans le cmd avec la commande curl suivante :
curl -X POST -H "Content-Type: application/x-www-form-urlencoded" https://test.api.amadeus.com/v1/security/oauth2/token -d "grant_type=client_credentials&client_id={Id_Key}&client_secret={Secret_Key}"
Et j'ai bien obtenu une réponse ! Je ne sais pas d'où cela pourrait venir, auriez-vous une idée ? Ais-je mal écris mon code php ?