【发布时间】:2015-04-15 18:32:07
【问题描述】:
我正在尝试在我的网站上为拥有 Google 帐户的人添加登录选项。我已经能够实现这个 Facebook,但是在使用 Google 获取用户帐户信息时遇到了问题。
我正在使用位于此处的 Google PHP SDK:https://github.com/google/google-api-php-client
$client = new Google_Client();
$client->setClientId($this->ci->config->item('client_id', 'google'));
$client->setClientSecret($this->ci->config->item('client_secret', 'google'));
$client->setRedirectUri($this->ci->config->item('callback_uri', 'google'));
$client->addScope('https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/plus.login');
$this->client->createAuthUrl();
但是现在我如何访问用户的电子邮件地址和其他基本信息?
我在 Google PHP SDK 中看到 getAccountInfo() 类中的 Google_Service_IdentityToolkit 方法。但是,它需要的参数是postBody,但我不确定如何获取/构建它。
【问题讨论】:
标签: php sdk google-oauth google-admin-sdk