首页 > 解决方案 > 这些是联系人 API 搜索方法的 People API 中的一个很好的替代品吗?

问题描述

现在我们正在尝试用 People API 替换 Contact API,这看起来很复杂。首先,没有办法在所有联系人中搜索(联系人、其他联系人、域联系人)。所以我们需要在三个不同的地方搜索并合并结果。或者我错过了什么?之前我们使用service.getFeed(query, ContactFeed.class);

第二个问题是 Contact API 中的搜索与 People API 中的搜索方式不同。联系人 API 将所有包含所提供查询的联系人作为字段中的子字符串返回。People API 仅返回包含以提供的查询开头的字段的联系人。

有没有人找到解决这些问题的方法?

UPDATE1: 在 People API 中,我们需要在三个不同的地方进行搜索:

https://developers.google.com/people/api/rest/v1/otherContacts/search - 在其他联系人列表中搜索; https://developers.google.com/people/api/rest/v1/people/searchContacts - 在联系人列表中搜索; https://developers.google.com/people/api/rest/v1/people/searchDirectoryPeople - 在用户的域目录中搜索;

这是一篇描述差异的文章: https ://www.nylas.com/blog/google-people-api-vs-contacts-api-migration Section "Parse Contact Info"

UPDATE2:这是联系人 API,Java 的代码:

Query query = new Query(new URL("https://www.google.com/m8/feeds/contacts/default/full"));
query.setMaxResults(Integer.MAX_VALUE);
query.setFullTextQuery("du"); // query itself

contactsService.getFeed(query, ContactFeed.class).getEntries();

标签: google-contacts-apigoogle-people-api

解决方案


使用 People API,您必须调用 3 个端点,而不是像使用 Contacts API 时那样调用 1 个端点。


推荐阅读