您可以透過多種方式要求共用使用者的聯絡資訊:
- 所有共用聯絡人
- 符合指定條件的一組聯絡人
- 單一共用聯絡人
- 聯絡人的相片
根據預設,動態饋給中的項目不會排序。
取得所有共用聯絡人
如要取得所有共用聯絡人,請向聯絡人動態饋給網址傳送 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 參考指南。
舉例來說,如要取得 2022 年 3 月 16 日後,example.com 的所有網域共用聯絡資料項目更新內容,請傳送 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