获取共享联系人
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
您可以通过多种方式请求共享的用户联系信息:
- 所有共享的联系人
- 一组符合指定条件的联系人
- 单个共享联系人
- 联系人的照片
默认情况下,Feed 中的条目不排序。
如需获取所有共享联系人,请向联系人 Feed 网址发送 HTTP GET
请求:
GET https://www.google.com/m8/feeds/contacts/DOMAIN/PROJECTION
替换以下内容:
DOMAIN
:您的网域的网址,例如 example.com。
PROJECTION
:用于指定 gd:extendedProperty
元素的投影值。如需查看支持的值列表,请参阅投影值。
Feed 会返回 HTTP 200 OK
状态代码和包含联系人的标准 Atom 1.0 Feed。以下是一个仅包含一条条目的联系人 Feed 示例:
<feed xmlns='http://www.w3.org/2005/Atom'
xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'
xmlns:gd='http://schemas.google.com/g/2005'
xmlns:gContact='http://schemas.google.com/contact/2008'
xmlns:batch='http://schemas.google.com/gdata/batch'>
<id>https://www.google.com/m8/feeds/contacts/example.com/base</id>
<updated>2008-03-05T12:36:38.836Z</updated>
<category scheme='http://schemas.google.com/g/2005#kind'
term='http://schemas.google.com/contact/2008#contact' />
<title type='text'>example.com's Contacts</title>
<link rel='http://schemas.google.com/g/2005#feed'
type='application/atom+xml'
href='https://www.google.com/m8/feeds/contacts/example.com/full' />
<link rel='http://schemas.google.com/g/2005#post'
type='application/atom+xml'
href='https://www.google.com/m8/feeds/contacts/example.com/full' />
<link rel='http://schemas.google.com/g/2005#batch'
type='application/atom+xml'
href='https://www.google.com/m8/feeds/contacts/example.com/full/batch' />
<link rel='self' type='application/atom+xml'
href='https://www.google.com/m8/feeds/contacts/example.com/full?max-results=25' />
<author>
<name>example.com</name>
<email>example.com</email>
</author>
<generator version='1.0' uri='https://www.google.com/m8/feeds/contacts'>
Contacts
</generator>
<openSearch:totalResults>1</openSearch:totalResults>
<openSearch:startIndex>1</openSearch:startIndex>
<openSearch:itemsPerPage>25</openSearch:itemsPerPage>
<entry>
<id>
https://www.google.com/m8/feeds/contacts/example.com/base/c9012de
</id>
<updated>2008-03-05T12:36:38.835Z</updated>
<category scheme='http://schemas.google.com/g/2005#kind'
term='http://schemas.google.com/contact/2008#contact' />
<title type='text'>Fitzgerald</title>
<gd:name>
<gd:fullName>Fitzgerald</gd:fullName>
</gd:name>
<link rel="http://schemas.google.com/contacts/2008/rel#photo" type="image/*"
href="http://google.com/m8/feeds/photos/media/example.com/c9012de"/>
<link rel='self' type='application/atom+xml'
href='https://www.google.com/m8/feeds/contacts/example.com/full/c9012de' />
<link rel='edit' type='application/atom+xml'
href='https://www.google.com/m8/feeds/contacts/example.com/full/c9012de/1204720598835000' />
<gd:phoneNumber rel='http://schemas.google.com/g/2005#home'
primary='true'>
456
</gd:phoneNumber>
<gd:extendedProperty name="pet" value="hamster" />
</entry>
</feed>
在单个响应中,Feed 不会返回超过 10MB 的数据。如需获取整个联系人列表,请反复点击返回 Feed 中的下一步链接,直到返回 Feed 中不再显示该链接。
您可以请求一组符合指定条件的联系人,例如请求在指定日期之后更新的联系人。不支持全文查询或按电子邮件地址查找联系人。如需查看受支持的查询参数的完整列表,请参阅 Domain Shared Contacts API 参考指南。
使用定义的参数向联系人 Feed 网址发送 HTTP GET
请求:
GET https://www.google.com/m8/feeds/contacts/DOMAIN/PROJECTION?PARAMETER
替换以下内容:
例如,如需获取 example.com 在 2022 年 3 月 16 日之后更新的所有网域共享联系人条目,请向网域共享联系人 Feed 网址发送 HTTP 请求,并将 updated-min
参数添加到请求网址:
GET https://www.google.com/m8/feeds/contacts/example.com/full?updated-min=2022-03-16T00:00:00
当您发送该 GET
请求时,服务器会返回 HTTP 200 OK
状态代码以及包含在指定日期之后创建或更新的所有网域共享联系人的 Feed。
在单个响应中,Feed 不会返回超过 10MB 的数据。如需获取符合指定条件的整个联系人名单,请反复点击返回 Feed 中的下一步链接,直到返回 Feed 中不再显示该链接。
跟踪增量更改
如需跟踪网域共享联系人名单的增量更改,请执行以下操作:
1. 发送 Feed 请求时,请跟踪 Feed 的 <updated>
元素的值。1. 您可以将查询参数 updated-min
设置为该 <updated>
值,并将 showdeleted
设置为 true
,从而仅获取自上次请求后发生更改的网域共享联系人。
如需获取单个共享联系人,您必须使用该联系人的自链接。您只能在分享的联系人 Feed 中找到相应联系人的条目,然后才能获取该联系人的自链接。如果您不确定应为自链接使用什么值,请参阅获取所有联系人和使用查询参数获取联系人。
- 如需获取特定网域共享联系人,请向联系人的自链接发送 HTTP
GET
请求:
GET https://www.google.com/m8/feeds/contacts/DOMAIN/PROJECTION/:SELF_LINK>
替换以下内容:
DOMAIN
:您的网域的网址,例如 example.com。
PROJECTION
:用于指定 gd:extendedProperty
元素的投影值。如需查看支持的值列表,请参阅投影值。
SELF_LINK
:表示单个共享联系人的唯一数字值,例如 12345。
然后,服务器会返回 HTTP 200 OK
状态代码和包含联系人的条目。
例如,如需获取将自链接设置为 https://www.google.com/m8/feeds/contacts/example.com/full/12345
的网域共享联系人,请发送以下 HTTP 请求:
GET https://www.google.com/m8/feeds/contacts/example.com/full/12345
后续步骤
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-25。
[null,null,["最后更新时间 (UTC):2025-03-25。"],[],[],null,["# Get shared contacts\n\nYou can request shared user contacts in a variety of\nways:\n\n- All shared contacts\n- A set of contacts that match a specified criteria\n- A single shared contact\n- A photo for a contact\n\nBy default, the entries in a feed aren't ordered.\n\nGet all shared contacts\n-----------------------\n\n1. To get all shared contacts, send an HTTP `GET` request to the\n contacts feed URL:\n\n ```xml\n GET https://www.google.com/m8/feeds/contacts/DOMAIN/PROJECTION\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eDOMAIN\u003c/var\u003e: The URL for your domain---for example, example.com.\n - \u003cvar translate=\"no\"\u003ePROJECTION\u003c/var\u003e: The projection value that specifies the `gd:extendedProperty` elements. For a list of supported values, see [Projection values](/workspace/admin/domain-shared-contacts/extended-properties-projections#projection_values).\n\n The feed returns an `HTTP 200 OK` status code and a standard Atom 1.0\n feed containing the contacts. The following is an example of a contacts\n feed with only one entry: \n\n ```xml\n \u003cfeed xmlns='http://www.w3.org/2005/Atom'\n xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'\n xmlns:gd='http://schemas.google.com/g/2005'\n xmlns:gContact='http://schemas.google.com/contact/2008'\n xmlns:batch='http://schemas.google.com/gdata/batch'\u003e\n \u003cid\u003ehttps://www.google.com/m8/feeds/contacts/example.com/base\u003c/id\u003e\n \u003cupdated\u003e2008-03-05T12:36:38.836Z\u003c/updated\u003e\n \u003ccategory scheme='http://schemas.google.com/g/2005#kind'\n term='http://schemas.google.com/contact/2008#contact' /\u003e\n \u003ctitle type='text'\u003eexample.com's Contacts\u003c/title\u003e\n \u003clink rel='http://schemas.google.com/g/2005#feed'\n type='application/atom+xml'\n href='https://www.google.com/m8/feeds/contacts/example.com/full' /\u003e\n \u003clink rel='http://schemas.google.com/g/2005#post'\n type='application/atom+xml'\n href='https://www.google.com/m8/feeds/contacts/example.com/full' /\u003e\n \u003clink rel='http://schemas.google.com/g/2005#batch'\n type='application/atom+xml'\n href='https://www.google.com/m8/feeds/contacts/example.com/full/batch' /\u003e\n \u003clink rel='self' type='application/atom+xml'\n href='https://www.google.com/m8/feeds/contacts/example.com/full?max-results=25' /\u003e\n \u003cauthor\u003e\n \u003cname\u003eexample.com\u003c/name\u003e\n \u003cemail\u003eexample.com\u003c/email\u003e\n \u003c/author\u003e\n \u003cgenerator version='1.0' uri='https://www.google.com/m8/feeds/contacts'\u003e\n Contacts\n \u003c/generator\u003e\n \u003copenSearch:totalResults\u003e1\u003c/openSearch:totalResults\u003e\n \u003copenSearch:startIndex\u003e1\u003c/openSearch:startIndex\u003e\n \u003copenSearch:itemsPerPage\u003e25\u003c/openSearch:itemsPerPage\u003e\n \u003centry\u003e\n \u003cid\u003e\n https://www.google.com/m8/feeds/contacts/example.com/base/c9012de\n \u003c/id\u003e\n \u003cupdated\u003e2008-03-05T12:36:38.835Z\u003c/updated\u003e\n \u003ccategory scheme='http://schemas.google.com/g/2005#kind'\n term='http://schemas.google.com/contact/2008#contact' /\u003e\n \u003ctitle type='text'\u003eFitzgerald\u003c/title\u003e\n \u003cgd:name\u003e\n \u003cgd:fullName\u003eFitzgerald\u003c/gd:fullName\u003e\n \u003c/gd:name\u003e\n \u003clink rel=\"http://schemas.google.com/contacts/2008/rel#photo\" type=\"image/*\"\n href=\"http://google.com/m8/feeds/photos/media/example.com/c9012de\"/\u003e\n \u003clink rel='self' type='application/atom+xml'\n href='https://www.google.com/m8/feeds/contacts/example.com/full/c9012de' /\u003e\n \u003clink rel='edit' type='application/atom+xml'\n href='https://www.google.com/m8/feeds/contacts/example.com/full/c9012de/1204720598835000' /\u003e\n \u003cgd:phoneNumber rel='http://schemas.google.com/g/2005#home'\n primary='true'\u003e\n 456\n \u003c/gd:phoneNumber\u003e\n \u003cgd:extendedProperty name=\"pet\" value=\"hamster\" /\u003e\n \u003c/entry\u003e\n \u003c/feed\u003e\n ```\n2. The feed doesn't return more than 10MB in a single response. To\n get the entire contact list, repeatedly follow the returned feed's\n **Next** link until you no longer see that link in the return feed.\n\nGet shared contacts by using query parameters\n---------------------------------------------\n\nYou can request a set of contacts that match a specified\ncriteria, such as requesting contacts updated after a given date. There is no\nsupport for full-text queries or locating a contact by email address. For a\ncomplete list of supported query parameters, see\n[Domain Shared Contacts API reference guide](https://developers.google.com/workspace/admin/domain-shared-contacts#Parameters).\n\n1. Send an `HTTP GET` request to the contacts feed URL with a defined\n parameter:\n\n ```xml\n GET https://www.google.com/m8/feeds/contacts/DOMAIN/PROJECTION?PARAMETER\n ```\n\n Replace the following:\n - \u003cvar translate=\"no\"\u003eDOMAIN\u003c/var\u003e: The URL for your domain---for example, example.com.\n - \u003cvar translate=\"no\"\u003ePROJECTION\u003c/var\u003e: The projection value that specifies the `gd:extendedProperty` elements. For a list of supported values, see [Projection values](/workspace/admin/domain-shared-contacts/extended-properties-projections#projection_values).\n - \u003cvar translate=\"no\"\u003ePARAMETER\u003c/var\u003e: One of the supported query parameters. For more information, see [Domain Shared Contacts API reference guide](/workspace/admin/domain-shared-contacts/contacts-feed).\n\n For example, to get all the domain shared contact entries updated after\n March 16, 2022 for example.com, send an HTTP request to the domain shared\n contact feed URL and add the `updated-min` parameter to the request URL: \n\n ```\n GET https://www.google.com/m8/feeds/contacts/example.com/full?updated-min=2022-03-16T00:00:00\n ```\n\n When you send that `GET` request, the server returns an HTTP `200 OK`\n status code and a feed containing any domain shared contacts that were\n created or updated after the date specified.\n2. The feed doesn't return more than 10MB in a single response. To\n get the entire contact list with the specified criteria, repeatedly\n follow the returned feed's **Next** link until you no longer see that link\n in the return feed.\n\n### Track incremental changes\n\nTo track incremental changes to a domain shared contact list, do the\nfollowing:\n1. When you send a request for a feed, keep track of the value of the\nfeed's `\u003cupdated\u003e` element.\n1. You can get only the domain shared contacts that have changed since\nthe previous request by setting the query parameter\n`updated-min` to that `\u003cupdated\u003e` value, and setting\n`showdeleted` to `true`.\n\nGet a single shared contact\n---------------------------\n\nTo get a single shared contact, you must use the contact's self link. You can\nonly get the shared contact's self link by locating the contact's entry in the\nshared contacts feed. If you're not sure what value to use for the self link,\nsee [Get all contacts](#get_all_shared_contacts)\nand\n[Get contacts by using query parameters](#get_shared_contacts_by_using_query_parameters).\n\n1. To get a specific domain shared contact, send an HTTP `GET` request to the self link of a contact: \n\n ```xml\n GET https://www.google.com/m8/feeds/contacts/DOMAIN/PROJECTION/:SELF_LINK\u003e\n ```\n Replace the following:\n\n- \u003cvar translate=\"no\"\u003eDOMAIN\u003c/var\u003e: The URL for your domain---for example, example.com.\n- \u003cvar translate=\"no\"\u003ePROJECTION\u003c/var\u003e: The projection value that specifies the `gd:extendedProperty` elements. For a list of supported values, see [Projection values](/workspace/admin/domain-shared-contacts/extended-properties-projections#projection_values).\n- \u003cvar translate=\"no\"\u003eSELF_LINK\u003c/var\u003e: A unique numerical value that represents a single shared contact---for example, 12345.\n\nThe server then returns an HTTP `200 OK` status code and an entry containing the\ncontact.\n\nFor example, to get a domain shared contact with self link set to\n`https://www.google.com/m8/feeds/contacts/example.com/full/12345`, send the\nfollowing HTTP request: \n\n```\nGET https://www.google.com/m8/feeds/contacts/example.com/full/12345\n```\n\nNext steps\n----------\n\n- [Get a photo for a shared contact](/workspace/admin/domain-shared-contacts/get-photo-shared-contacts)"]]