如何使用google + api获取朋友的电子邮件?

我创建了一个登录Google+的应用程序并收到朋友的电子邮件。 我成功validation并获得令牌,但当我获取朋友列表时,任何一个朋友的用户类都有电子邮件= null …

这是代码(已登录并获取authenticator类后):

// Generated libraries for Google APIs using Google.Apis.Authentication.OAuth2; using Google.Apis.Authentication.OAuth2.DotNetOpenAuth; using Google.Apis.Services; using Google.Apis.Util; using Google.Apis.Plus.v1; using Google.Apis.Plus.v1.Data; // For OAuth2 using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OAuth2; //....code for authentication skipped .... //...callback from json (authentication success) PlusService ps = new PlusService(new BaseClientService.Initializer() { Authenticator = authenticator }); PeopleFeed peopleFeed = ps.People.List("me", PeopleResource.CollectionEnum.Visible).Fetch(); //After that when i inspect peopleFeed[0].Emails <--- this is null.. 

任何帮助?

Google+ API仅返回公开信息。 因此,即使被允许查看某人的电子邮件地址,也不一定意味着该信息是公开的并且将被退回。

此外, https://developers.google.com/+/api/latest/people/list上的文档仅保证返回的人员列表将包含此人

  • ID
  • 显示名称
  • 图片
  • url

要获得有关此人的其他信息,您需要对该ID进行操作。 但是,请注意,如果该信息不公开,您可能仍然无法收到他们的电子邮件。

您还可以使用Contacts v3 API获取朋友的电子邮件地址。 您可以通过查看XML响应中返回的联系人的gContact:website元素,将其交叉映射到Google+联系人:

  

在该元素的href属性中,1234567890是与Google+ API的people.list中相关人员资源的id字段匹配的人员标识符。

请注意,无法保证配置文件链接可以返回联系人条目。 如果联系人尚未与Google+个人资料相关联,则会发生这种情况。

我的第一个猜测是它是一个权利管理问题。 我记得当我要求提供Google API密钥时,我不得不提到我想要获得的信息。

您是否可以在Google Developer网络中检查您的API密钥设置,看看是否需要在那里启用它?