创建共享联系人

设置身份验证后,使用 Domain Shared Contacts API 将新的共享联系人条目发布到 Google Workspace 网域。共享联系人最长可能需要 24 小时才能显示在自动补全功能和通讯录管理器中。

  1. 创建共享联系人的 XML 表示形式,以作为 Contact kind 的 Atom <entry> 元素发布:

    <atom:entry xmlns:atom='http://www.w3.org/2005/Atom'
        xmlns:gd='http://schemas.google.com/g/2005'>
      <atom:category scheme='http://schemas.google.com/g/2005#kind'
        term='http://schemas.google.com/contact/2008#contact' />
      <gd:name>
         <gd:givenName>FIRST_NAME</gd:givenName>
         <gd:familyName>LAST_NAME</gd:familyName>
         <gd:fullName>FIRST_NAME LAST_NAME</gd:fullName>
      </gd:name>
      <atom:content type='text'>NOTES</atom:content>
      <gd:email rel='http://schemas.google.com/g/2005#work'
        primary='true'
        address='PRIMARY_EMAIL_ADDRESS' displayName='PREFERRED_NAME' />
      <gd:email rel='http://schemas.google.com/g/2005#home'
        address='SECONDARY_EMAIL_ADDRESS' />
      <gd:phoneNumber rel='http://schemas.google.com/g/2005#work'
        primary='true'>
        PRIMARY_PHONE_NUMBER
      </gd:phoneNumber>
      <gd:phoneNumber rel='http://schemas.google.com/g/2005#home'>
        SECONDARY_PHONE_NUMBER
      </gd:phoneNumber>
      <gd:im address='INSTANT_MESSAGING_ADDRESS'
        protocol='http://schemas.google.com/g/2005#GOOGLE_TALK'
        primary='true'
        rel='http://schemas.google.com/g/2005#home' />
      <gd:structuredPostalAddress
          rel='http://schemas.google.com/g/2005#work'
          primary='true'>
        <gd:city>CITY_NAME</gd:city>
        <gd:street>ADDRESS</gd:street>
        <gd:region>REGION_NAME</gd:region>
        <gd:postcode>POST_CODE</gd:postcode>
        <gd:country>COUNTRY_NAME</gd:country>
        <gd:formattedAddress>
          FORMATTED_ADDRESS
        </gd:formattedAddress>
      </gd:structuredPostalAddress>
    </atom:entry>

    替换以下内容:

    • FIRST_NAME:联系人的名字,例如 Dana。
    • LAST_NAME:联系人的姓氏,例如 A。
    • PRIMARY_EMAIL_ADDRESS:首选电子邮件地址,例如 dana@example.com。
    • PREFERRED_NAME:用户的显示名称,例如 Dana A。
    • SECONDARY_EMAIL_ADDRESS:辅助电子邮件地址,例如 da@example.com。
    • PRIMARY_PHONE_NUMBER:首选电话号码,例如 800-555-0100。
    • SECONDARY_PHONE_NUMBER:辅助电话号码,例如 800-555-0101。
    • INSTANT_MESSAGING_ADDRESS:即时通讯电子邮件地址,例如 dana@example.com。
    • CITY_NAME:城市名称,例如 Mountain View。
    • ADDRESS:街道地址,例如 1800 Amphibious Blvd.
    • REGION_NAME:州或省,例如加利福尼亚州 (CA)。
    • POST_CODE:邮政编码,例如 94045。
    • COUNTRY_NAME:国家/地区,例如美国。
    • FORMATTED_ADDRESS:使用本地惯例设置的地址格式,例如 1800 Amphibious Blvd.、Mountain View, CA 94045, USA.
  2. 如需发布此条目,请将其发送到联系人列表 Feed 网址:

    1. 使用 application/atom+xml 内容类型将 Atom <entry> 元素放置在新的 POST 请求的正文中。
    2. 向 Feed 网址发送 POST 请求。

    例如,如需将某个联系人添加到 example.com 列表,请向以下网址发送 POST 请求:

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

    服务器会创建相应联系人,并返回 HTTP 201 CREATED 状态代码以及新的联系人条目。返回的条目包含服务器生成的元素,例如 <id>

    如果请求失败,服务器会返回其他状态代码。请参阅 Google Data API 协议参考文档

后续步骤