【发布时间】:2014-07-21 04:56:13
【问题描述】:
实际上,我使用 javascript 客户端来检索用户个人资料信息。所以我使用了以下 api 调用
gapi.client.load('plus', 'v1', function() {
var request = gapi.client.plus.people.get({
'userId': 'me'
});
request.execute(function(resp) {
});
});
所以这项工作正常,我检索了用户详细信息。但现在我需要使用 php.ini 检索记录的用户详细信息。我使用了 google-php-client-lib 这是我的代码
$client = new Google_Client();
$client->setClientId('xxx');
$client->setClientSecret('xxx');
$client->setDeveloperKey('xxx');
$client->setRedirectUri('http://localhost');
$client->setScopes(array('https://www.googleapis.com/auth/plus.me'));
try{
$plus = new Google_Service_Plus($client);
return $person = $plus->people->get('me');
} catch (Google_Service_Exception $e){
error_log('>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'.$e->getMessage());
}
但这会返回以下异常
调用 GET https://www.googleapis.com/plus/v1/people/me?key=xxx 时出错:(401) 凭据无效。实际上,我使用了与 javascript 相同的凭据。请帮我。我做错了什么?
【问题讨论】:
-
您的问题中似乎遗漏了一些信息。在第一种情况下,您如何进行身份验证?您使用的是 Google+ 登录按钮还是其他什么?
标签: php google-plus google-api-php-client