Je dois obtenir le jeton google valide pour utiliser les API Google, mais mon code ne fonctionne pas. pourriez-vous me conseiller s'il vous plaît?Get Google API Token
$client_id = '495225261106.apps.googleusercontent.com';
$client_secret = urlencode('MY_SECRET_CDE');
$redirect_uri = urlencode('http://MYPAGE.net/test.php');
//$grant_type = urlencode('authorization_code'); //it does not work either.
$grant_type = 'authorization_code';
$post_string = "code=4/P7q7W91a-oMsCeLvIaQm6bTrgtp6&client_id={$client_id}&client_secret={$client_secret}&redirect_uri={$redirect_uri}&grant_type={$grant_type}";
//echo_key_value('post_string',$post_string);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://accounts.google.com/o/oauth2/token');
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$result = curl_exec($ch); // Execute the HTTP command
$errmsg = curl_error($ch);
if($errmsg) echo $errmsg;
// sortie: { "erreur": "invalid_grant"} //
Merci!
Je suis en train de mettre en œuvre ce en javascript mais courir dans la même erreur. J'ai essayé d'utiliser curl depuis la ligne de commande et toujours pas de chance. J'ai suivi les instructions sur [cette page] (http://code.google.com/apis/accounts/docs/OAuth2.html) à un T. – Abe