Shared Contacts API允許客戶端應用程序檢索和更新共享給Google Apps域中所有用戶的外部聯繫人。共享聯繫人對應用程序域的所有用戶都可見,並且所有Google服務都可以訪問聯繫人列表。
創建要發佈的共享聯繫人的XML表示形式。該XML需要在聯繫人種類的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='[email protected]' displayName='E. Bennet' />
<gd:email rel='http://schemas.google.com/g/2005#home'
address='[email protected]' />
<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='[email protected]'
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
的谷歌服務器使用您發送的條目中的聯繫人,然後返回一個HTTP 201 CREATED
狀態代碼以及並以<entry>
元素的形式提供新聯繫人的副本。
您的客戶端應用程序可以使用共享聯繫人API來創建新的共享聯繫人,編輯或刪除現有共享聯繫人以及查詢符合特定條件的共享聯繫人。
要刪除聯繫人,請將授權的DELETE
請求發送到聯繫人的編輯網址。
的URL的形式是:
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
嗯,我知道所有這些步驟,通常他們工作沒有任何問題。在這種情況下,提到的聯繫人沒有ID!它只顯示在Directory文件夾的列表中,但不能像普通聯繫人條目那樣刪除。 – valley