您可以透過多種方式要求共用使用者聯絡人:
- 所有共用聯絡人
- 符合指定條件的一組聯絡人
- 單一共用聯絡人
- 聯絡人相片
根據預設,動態饋給中的項目不會排序。
取得所有共用聯絡人
如要取得所有共用聯絡人,請傳送 HTTP
GET
要求至聯絡人動態饋給網址:GET https://www.google.com/m8/feeds/contacts/DOMAIN/PROJECTION
更改下列內容:
DOMAIN
:您網域的網址,例如 example.com。PROJECTION
:指定gd:extendedProperty
元素的投影值。如需支援的值清單,請參閱投影值。
動態饋給會傳回
HTTP 200 OK
狀態碼,以及包含聯絡人的標準 Atom 1.0 動態饋給。以下是只有一個項目的聯絡人動態饋給範例:<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>
動態饋給在單次回應中傳回的結果不得超過 10 MB。如要取得完整的聯絡人清單,請重複執行傳回的動態饋給的「Next」連結,直到不再在傳回動態饋給中看到該連結。
使用查詢參數取得共用聯絡人
您可以要求一組符合特定條件的聯絡人,例如要求在特定日期後更新聯絡人。我們並未支援全文查詢,也無法透過電子郵件地址尋找聯絡人。如需支援的查詢參數完整清單,請參閱 Domain Shared Contacts API 參考指南。
使用已定義的參數,將
HTTP GET
要求傳送至聯絡人動態饋給網址:GET https://www.google.com/m8/feeds/contacts/DOMAIN/PROJECTION?PARAMETER
更改下列內容:
DOMAIN
:您網域的網址,例如 example.com。PROJECTION
:指定gd:extendedProperty
元素的投影值。如需支援的值清單,請參閱投影值。PARAMETER
:其中一個支援的查詢參數。詳情請參閱 Domain Shared Contacts API 參考指南。
舉例來說,如要取得 example.com 於 2022 年 3 月 16 日之後更新的所有網域共用聯絡人項目,請將 HTTP 要求傳送至共用聯絡人動態饋給網址,然後在要求網址中加入
updated-min
參數:GET https://www.google.com/m8/feeds/contacts/example.com/full?updated-min=2022-03-16T00:00:00
當您傳送該
GET
要求時,伺服器會傳回 HTTP200 OK
狀態碼,以及包含在指定日期之後建立或更新的任何網域共用聯絡人的動態饋給。動態饋給在單次回應中傳回的結果不得超過 10 MB。如要透過指定條件取得完整的聯絡人清單,請重複追蹤傳回的動態饋給的「Next」連結,直到不再在傳回動態饋給中看到該連結。
追蹤成效增幅的變更
如要追蹤網域共用聯絡人清單的逐步變更,請執行下列步驟:
1. 傳送動態饋給要求時,請持續追蹤動態饋給中的 <updated>
元素值。1. 如要取得在上一個要求後有所變更的網域共用聯絡人,請將查詢參數 updated-min
設為該 <updated>
值,並將 showdeleted
設為 true
。
取得單一共用聯絡人
如要取得單一共用聯絡人,必須使用聯絡人的自我連結。您只能在共用聯絡人動態消息中尋找聯絡人的項目,以取得共用聯絡人的自我連結。如果您不確定自我連結要使用的值,請參閱「取得所有聯絡人」和「使用查詢參數取得聯絡人」。
- 如要取得特定網域共用聯絡人,請傳送 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