获取共享联系人

您可以通过多种方式请求共享的用户联系人:

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

默认情况下,Feed 中的条目未进行排序。

获取所有共享联系人

  1. 要获取所有共享联系人,请向联系人 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>
    
  2. Feed 在单个响应中返回的数据量不会超过 10 MB。如需获取整个联系人列表,请反复点击所返回 Feed 的 Next 链接,直到返回 Feed 中不再显示该链接。

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

您可以请求一组符合指定条件的联系人,例如请求在给定日期后更新的联系人。不支持全文查询或按电子邮件地址查找联系人。如需查看受支持查询参数的完整列表,请参阅 Domain Shared Contacts API 参考指南

  1. 使用定义的参数向联系人 Feed 网址发送 HTTP GET 请求:

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

    请替换以下内容:

    • DOMAIN:您的网域的网址,例如 example.com。
    • PROJECTION:用于指定 gd:extendedProperty 元素的投影值。如需查看支持的值的列表,请参阅投影值
    • PARAMETER:支持的查询参数之一。如需了解详情,请参阅 Domain Shared Contacts API 参考指南

    例如,如需获取在 2022 年 3 月 16 日之后更新 example.com 的所有网域共享联系人条目,请向网域共享联系人 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。

  2. Feed 在单个响应中返回的数据量不会超过 10 MB。如需获取符合指定条件的完整联系人列表,请反复点击所返回 Feed 的 Next 链接,直到返回 Feed 中不再显示该链接。

跟踪增量更改

如需跟踪对网域共享联系人列表的增量更改,请执行以下操作: 1. 在发送 Feed 请求时,请跟踪 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:用于指定 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

后续步骤