获取共享联系人

通过以下方式请求共享的用户联系信息:

  • 所有共享的联系人
  • 一组符合指定条件的联系人
  • 单个共享联系人
  • 联系人的照片

默认情况下,Feed 中的条目是无序的。

获取所有共享联系人

  1. 如需获取所有共享联系人,请向联系人 Feed 网址发送 HTTP GET 请求:

    GET https://www.google.com/m8/feeds/contacts/DOMAIN/PROJECTION

    替换以下内容:

    • DOMAIN:您的网域。例如,example.com。
    • PROJECTION:投影值。如需查看支持的值,请参阅投影值

    服务器返回 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>
  2. Feed 在单个响应中返回的最大数据量为 10MB。如需获取完整列表,请在返回的 Feed 中反复点击下一页链接。

使用查询参数获取共享联系人

请求符合指定条件的联系人,例如在特定日期之后更新的联系人。不支持全文查询和电子邮件地址查找。 如需了解所有查询参数,请参阅 Domain Shared Contacts API 参考指南

  1. 向联系人 Feed 网址发送带有参数的 HTTP GET 请求:

    GET https://www.google.com/m8/feeds/contacts/DOMAIN/PROJECTION?PARAMETER

    替换以下内容:

    例如,如需获取 example.com 上在 2022 年 3 月 16 日之后更新的条目,请添加 updated-min 参数:

    GET https://www.google.com/m8/feeds/contacts/example.com/full?updated-min=2022-03-16T00:00:00
    

    服务器会返回 HTTP 200 OK 状态代码以及包含所有匹配项的 Feed。

  2. Feed 在单个响应中返回的最大数据量为 10MB。如需获取完整列表,请在返回的 Feed 中反复点击下一页链接。

跟踪增量更改

如需跟踪对网域共享的联系人列表所做的更改,请执行以下操作: 1. 记录 Feed 的 <updated> 元素的值。 1. 通过将 updated-min 设置为该 <updated> 值并将 showdeleted 设置为 true,请求已更改的联系人。

获取单个共享联系人

如需获取特定联系人,请使用该联系人的自链接,您可以在共享联系人 Feed 中找到该链接。如需了解详情,请参阅获取所有共享联系人

  1. 如需获取特定联系人,请向相应联系人的自链接发送 HTTP GET 请求:
    GET https://www.google.com/m8/feeds/contacts/DOMAIN/PROJECTION/SELF_LINK
    替换以下内容:
  • DOMAIN:您的网域,例如 example.com。
  • PROJECTION:投影值。如需查看支持的值,请参阅投影值
  • SELF_LINK:联系人的唯一数值。

服务器会返回 HTTP 200 OK 状态代码和相应联系人条目。

例如,如需获取具有自链接 https://www.google.com/m8/feeds/contacts/example.com/full/12345 的联系人,请执行以下操作:

GET https://www.google.com/m8/feeds/contacts/example.com/full/12345

后续步骤