无法从google api OAuth2刷新令牌

Here is my php script RefreshToken.php

<?php
$url = 'https://accounts.google.com/o/oauth2/token';
$post_data = array(
                    'code'          =>   'xxxxxxxx',
                    'client_id'     =>   'xxxxxxxxxxx',
                    'client_secret' =>   'xxxxxxxxxxxxx',
                    'redirect_uri'  =>   'http://localhost/googleapi/AuthenticationCode.php',
                    'grant_type'    =>   'authorization_code',
                    );
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

$result = curl_exec($ch);
$token = json_decode($result);

echo $token->refresh_token . "
";
?>

Run PHP CLI

php -q RefreshToken.php

PHP Notice: Undefined property: stdClass::$refresh_token in /var/www/googleapi/RefreshToken.php on line 20

查看全部
du0173
du0173
2015/06/08 12:00
  • php
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复