Google与联络人API的People API [英] People API of google versus contacts 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屋!