如何获取电子邮件地址以及Google加上API的人员列表 [英] How to get email address along with people list in google plus API

查看:213
本文介绍了如何获取电子邮件地址以及Google加上API的人员列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网络应用程序中使用了Google plus API。我可以从谷歌中提取所有的人加$ /

我的代码是

  $ 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->客户端);
$ this-> auth2 = new Google_Oauth2Service($ this->客户端);

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

在这里,我收到了我圈子中所有人的列表。但我没有收到人们的电子邮件地址和生日。我怎么能得到那些呢?

解决方案

一旦你有一个Google+ ID列表,你需要通过一个people.get来获取[public]这些用户的配置文件数据。在PHP中,此调用看起来像 $ me = $ plus-> people-> get('me'); 。对于授权用户,可以使用'me'关键字。否则,您可以使用Google+ ID进行通话。



一旦你打了电话,你可以拉出与你相关的属性(完整列表: a href =https://developers.google.com/+/api/latest/people =nofollow> https://developers.google.com/+/api/latest/people ) 。



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


I'm using google plus API in my web app. I could pull out all people from google plus

My code is

$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');

Here I'm getting list of all the peoples in my circle. But I dont get people's email address and birthdays. How can I get those too?

解决方案

Once you have a list of Google+ IDs, you will need to make a people.get call to gain the [public] profile data for those users. In PHP, this call looks like $me = $plus->people->get('me');. For an authorized user, the 'me' keyword can be used. Otherwise, you can make the call using a Google+ ID.

Once you have made that call, you can pull out the attributes that are relevant to you (full list: https://developers.google.com/+/api/latest/people).

However, to get the Google email address for a user, you will need to include the https://www.googleapis.com/auth/userinfo.email scope in addition to the plus.login scope. This means that you may only get the email addresses of authorized users.

这篇关于如何获取电子邮件地址以及Google加上API的人员列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆