Shared Contacts API 允许客户端应用程序检索和更新与 Google Apps 域中的所有用户共享的外部联系人。 Apps 域的所有用户都可以看到共享的联系人,并且所有 Google 服务都可以访问联系人列表。
创建要发布的共享联系人的 XML 表示。此 XML 需要采用 Contact 类型的 Atom 元素的形式,可能如下所示:
<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>Elizabeth</gd:givenName>
<gd:familyName>Bennet</gd:familyName>
<gd:fullName>Elizabeth Bennet</gd:fullName>
</gd:name>
<atom:content type='text'>Notes</atom:content>
<gd:email rel='http://schemas.google.com/g/2005#work'
primary='true'
address='liz@gmail.com' displayName='E. Bennet' />
<gd:email rel='http://schemas.google.com/g/2005#home'
address='liz@example.org' />
<gd:phoneNumber rel='http://schemas.google.com/g/2005#work'
primary='true'>
(206)555-1212
</gd:phoneNumber>
<gd:phoneNumber rel='http://schemas.google.com/g/2005#home'>
(206)555-1213
</gd:phoneNumber>
<gd:im address='liz@gmail.com'
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>Mountain View</gd:city>
<gd:street>1600 Amphitheatre Pkwy</gd:street>
<gd:region>CA</gd:region>
<gd:postcode>94043</gd:postcode>
<gd:country>United States</gd:country>
<gd:formattedAddress>
1600 Amphitheatre Pkwy Mountain View
</gd:formattedAddress>
</gd:structuredPostalAddress>
</atom:entry>
https://www.google.com/m8/feeds/contacts/example.com/full
Google 服务器使用您发送的条目创建一个联系人,然后返回一个HTTP 201 CREATED 状态代码,以及一个<entry> 元素形式的新联系人副本。
您的客户端应用程序可以使用共享联系人 API 来创建新的共享联系人、编辑或删除现有的共享联系人以及查询符合特定条件的共享联系人。
要删除联系人,请向联系人的编辑 URL 发送授权的 DELETE 请求。
网址格式为:
https://www.google.com/m8/feeds/contacts/{userEmail}/full/{contactId}
用适当的值代替 userEmail 和 contactID。
注意:特殊的 userEmail 值默认值可用于引用经过身份验证的用户。
为确保发送到 API 的请求不会覆盖其他客户端的更改,应在请求标头中提供联系人条目的 Etag。
If-Match: Etag
如果Etag 已过时,服务器会以HTTP 412 Precondition Failed 状态码进行响应。
<!-- Request -->
DELETE /m8/feeds/contacts/default/full/contactId
If-match: Etag
...
<!-- Response -->
HTTP/1.1 200 OK