php - 如何获取电子邮件地址以及 google plus API 中的人员列表

标签 php email google-plus google-api-php-client

我在我的网络应用程序中使用 google plus API。我可以从 google plus 中拉出所有人

我的代码是

$this->client = new Google_Client();
        $this->client->setApplicationName($CI->config->item('application_name', 'googleplus'));
        $this->client->setClientId($CI->config->item('client_id', 'googleplus'));
        $this->client->setClientSecret($CI->config->item('client_secret', 'googleplus'));
        $this->client->setRedirectUri($CI->config->item('redirect_uri', 'googleplus'));
        $this->client->setDeveloperKey($CI->config->item('api_key', 'googleplus'));

        $this->plus = new Google_PlusService($this->client);
              $this->auth2 = new Google_Oauth2Service($this->client);

$peoples = $this->plus->people->listPeople('me','visible');

在这里,我得到了我圈子中所有人的名单。但我不知道人们的电子邮件地址和生日。我怎样才能得到那些?

最佳答案

获得 Google+ ID 列表后,您需要调用 people.get 电话以获取这些用户的 [public] 个人资料数据。在 PHP 中,此调用类似于 $me = $plus->people->get('me');。对于授权用户,可以使用“我”关键字。否则,您可以使用 Google+ ID 调用电话。

调用后,您可以提取与您相关的属性(完整列表:https://developers.google.com/+/api/latest/people)。

但是,要获取用户的 Google 电子邮件地址,您需要包括 https://www.googleapis.com/auth/userinfo.email 范围以及 plus.login 范围。这意味着您只能获得授权用户的电子邮件地址。

关于php - 如何获取电子邮件地址以及 google plus API 中的人员列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17672709/

相关文章:

node.js - Nodejs Nodemailer : Sendgrid SMTP username & password to API key using existing code error : 550

javascript - 为什么加载 Google+ JS 客户端时出现 "Invalid gadgets.rpc token"错误?

ios - Google plus 登录在 iOS 应用程序中不起作用

PHP - MSSQL 从存储过程获取结果

php - MySQL:根据两个不同表中的多个键选择几行

php - 在 PHP mail() 函数中使用特殊字符

javascript - 我们可以使用 moment.insert 方法在您的 g+ 墙上发布/发布一些内容吗?

php - 上传数据库中的图像

php - 如何使用str_replace替换单引号和双引号

mysql - 如何使用MySQL服务器发送电子邮件?