Google与联络人API的People API [英] People API of google versus contacts API

查看:119
本文介绍了Google与联络人API的People API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在尝试使用user的google帐户获取联系人时,在使用people API之后我遇到了一些问题.它仅返回列出的所有电子邮件地址中的几个电子邮件地址.访问令牌和所有范围均已正确设置. 以下代码:

While trying to fetch contacts using google account of user , I am facing some issues after using people API.It only returns few email addresses out of all listed ones.Access token and all scopes have been set correctly. Code for following :

People peopleService = new People.Builder(httpTransport, jsonFactory, credential)
                    .build();
ListConnectionsResponse response = peopleService.people().connections().list("people/me")
                    .setPageSize(500).setSortOrder("FIRST_NAME_ASCENDING")
                    .setAccessToken(tokenResponse.getAccessToken())
                    .setAlt("json")
                    .setRequestMaskIncludeField("person.names,person.emailAddresses,person.phoneNumbers")
                    . execute();
   connections = response.getConnections();

如果我使用的是Google的联系人API,那么与此相反,我收到的电子邮件地址多于people.Contact API的代码:

Instead of this if I use contact API of google then I am getting more no of email addresses than people.Code for contact API :

URL feedUrl = new URL("https://www.google.com/m8/feeds/contacts/default/full");
    ContactFeed resultFeed = myService.getFeed(feedUrl, ContactFeed.class);

    // Print the results
    System.out.println(resultFeed.getTitle().getPlainText());
    for (ContactEntry entry : resultFeed.getEntries()) {
          ....
          .....
          .......
 }

我想知道两者之间是否有区别,以及为了获得更好的结果而必须使用哪一个,还是我错过了一些东西.请提出建议.谢谢.. !!

I want to know if there is any difference between both of them and which one i have to use for better results or am I missing something. please suggest. Thanks..!!

推荐答案

People API是最新的.通过阅读 Google的博客公告,People API简化了需要分别调用Google+ API和Contacts API.现在,您只需要使用一个即可.

People API is more up-to-date. Reading through Google's blog announcement, People API simplifies what needed to be separate calls to Google+ API and Contacts API. Now you only need to use one.

"新的People API使用最新的协议和技术, 最终将取代使用GData的Contacts API 协议"

"The new People API uses the newest protocols and technologies and will eventually replace the Contacts API which uses the GData protocol"

获取用户的连接列表时,请确保在使用时指定正确的作用域.

When getting the user's list of connections, be sure to specify the correct scopes when using it.

https://www.googleapis.com/auth/contacts-要求您的应用具有对经过身份验证的用户的Google通讯录中的通讯录的读写权限. https://www.googleapis.com/auth/contacts.readonly-要求您的应用具有对经过身份验证的用户的Google通讯录中的通讯录的读取权限.

https://www.googleapis.com/auth/contacts - Requests that your app be given read and write access to the contacts in the authenticated user’s Google Contacts. https://www.googleapis.com/auth/contacts.readonly - Requests that your app be given read access to the contacts in the authenticated user’s Google Contacts.

选中此链接以了解People API和Contacts API之间的相似之处和不同之处.

这篇关于Google与联络人API的People API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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