[英]May I use this logic to get the Google Account email address (using Google+ API (People) )
when I use 「 https://www.googleapis.com/plus/v1/people/ {userId}」to get the json of people profile, I use the code below to get user's google account email(.NET) but is there any guarantee that the user's google account is the first one of emails[] array? 当我使用“ https://www.googleapis.com/plus/v1/people/ {userId}”来获取人物个人资料的json时,我使用下面的代码来获取用户的google帐户电子邮件(.NET),但是是否可以保证用户的Google帐户是emails []数组的第一个? I doubt if this is the right way to get a user's email.
我怀疑这是否是获取用户电子邮件的正确方法。
if (json.emails != null)
{
if (json.emails.Count != 0)
{
if (json.emails[0].type == "account")
email = json.emails[0].value;
}
}
First of all I would use https://www.googleapis.com/plus/v1/people/me
as its the current authenticated user you are after. 首先,我将使用
https://www.googleapis.com/plus/v1/people/me
作为您正在https://www.googleapis.com/plus/v1/people/me
的当前经过身份验证的用户。
If you read the documentation found at: People 如果您阅读位于以下位置的文档: 人员
Emails is a list with value and the type. Type = account is what you are after.
The type of address. 地址类型。 Possible values include, but are not limited to, the following values:
可能的值包括但不限于以下值:
The list may contain more the one email address, but just scan though them looking for the one that is set to type = account. 该列表可能包含更多的一个电子邮件地址,但是只要扫描它们以查找设置为= account的那个电子邮件地址即可。
Note: Scroll to the bottom of this page you can play with the response: https://developers.google.com/+/api/latest/people/get 注意:滚动到此页面底部,您可以使用以下响应: https : //developers.google.com/+/api/latest/people/get
(Remember to authenticate it in the top of the "Try it!" form, also in the userId field just type me) (请记住在“尝试它!”表单的顶部进行身份验证,也请在userId字段中键入我)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.