gpt4 book ai didi

android - google 的 People API 与 contacts API

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:42:21 24 4
gpt4 key购买 nike

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

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 而不是这个,那么我得到的电子邮件地址比人多。联系 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()) {
....
.....
.......
}

我想知道它们之间是否有任何区别,我必须使用哪个以获得更好的结果,或者我是否遗漏了什么。请建议。谢谢..!!

最佳答案

People API 是最新的。通读Google's blog announcement , People API 简化了对 Google+ API 和 Contacts API 的单独调用。现在你只需要使用一个。

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

获取用户的 list of connections 时, 请务必指定 correct scopes使用时。

https://www.googleapis.com/auth/contacts - 请求为您的应用授予对经过身份验证的用户的 Google 通讯录中联系人的读写权限。https://www.googleapis.com/auth/contacts.readonly - 请求您的应用获得对经过身份验证的用户的 Google 通讯录中联系人的读取权限。

检查这个link for similarities and differences People API 和 Contacts API 之间。

关于android - google 的 People API 与 contacts API,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37695695/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com