執行批次作業

批次要求可讓伺服器透過單一 HTTP 要求執行多項作業,藉此提升應用程式的回應速度。如要執行批次作業,請建立聯絡人動態饋給,並為每項作業新增項目。

批次要求最多只能包含 100 項作業。詳情請參閱「Google Data Protocol 中的批次處理」。變更最多可能需要 24 小時才會反映在自動完成功能和聯絡人管理工具中。

下列程式碼範例顯示建立 2 個共用聯絡人的批次要求。批次要求也可以查詢、更新及刪除聯絡人。更新及刪除項目時,需要樂觀並行的編輯連結。

<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns='http://www.w3.org/2005/Atom'
      xmlns:gContact='http://schemas.google.com/contact/2008'
      xmlns:gd='http://schemas.google.com/g/2005'
      xmlns:batch='http://schemas.google.com/gdata/batch'>
  <category scheme='http://schemas.google.com/g/2005#kind'
      term='http://schemas.google.com/g/2008#contact' />
  <entry>
    <batch:id>1</batch:id>
    <batch:operation type='insert' />
    <category scheme='http://schemas.google.com/g/2005#kind'
      term='http://schemas.google.com/g/2008#contact'/>
    <gd:name>
      <gd:givenName>FIRST_NAME</gd:fullName>
      <gd:familyName>LAST_NAME</gd:fullName>
    </gd:name>
    <gd:email rel='http://schemas.google.com/g/2005#home'
      address='EMAIL_ADDRESS' primary='true'/>
  </entry>
  <entry>
    <batch:id>2</batch:id>
    <batch:operation type='insert' />
    <category scheme='http://schemas.google.com/g/2005#kind'
      term='http://schemas.google.com/g/2008#contact'/>
    <gd:name>
      <gd:givenName>FIRST_NAME</gd:fullName>
      <gd:familyName>LAST_NAME</gd:fullName>
    </gd:name>
    <gd:email rel='http://schemas.google.com/g/2005#home'
      address='EMAIL_ADDRESS'
      primary='true'/>
  </entry>
</feed>

更改下列內容:

  • FIRST_NAME:聯絡人的名字。
  • LAST_NAME:聯絡人的姓氏。
  • EMAIL_ADDRESS:偏好的電子郵件地址。