ดำเนินการแบบเป็นกลุ่ม
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
หากคุณดําเนินการหลายรายการ เวลาในการส่งและรับข้อความ HTTP ทั้งหมดอาจทําให้แอปทำงานช้าและไม่ตอบสนอง เมื่อใช้คำขอแบบเป็นกลุ่ม คุณจะทําให้เซิร์ฟเวอร์ดําเนินการหลายรายการได้โดยใช้คําขอ 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
: ชื่อนามสกุลของรายชื่อติดต่อที่แชร์ เช่น Alex
LAST_NAME
: นามสกุลของรายชื่อติดต่อที่แชร์ เช่น Kim
EMAIL_ADDRESS
: อีเมลที่ต้องการของรายชื่อติดต่อที่แชร์ เช่น alk@gmail.com
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-03-25 UTC
[null,null,["อัปเดตล่าสุด 2025-03-25 UTC"],[],[],null,["# Perform batch operations\n\nIf you're performing several operations, the time it takes to send and receive\nall those HTTP messages can make your app slow and unresponsive. With batch\nrequests, you can have the server perform multiple operations with a single HTTP\nrequest. The basic idea is that you create a contacts feed and add an entry for\neach operation that you want to perform.\n\nBatch requests are limited to 100 operations at a time. You can find more\ninformation about batch operations in\n[Batch Processing in the Google Data Protocol](https://developers.google.com/gdata/docs/batch).\nChanges can take up to 24 hours to be reflected in the email address\nautocomplete and the contact manager.\n\nThe following code sample shows a batch request that creates 2 shared\ncontacts; however, you can also use a batch request to query, update, and delete\ncontacts. The update and delete entries require an edit link for\n[optimistic concurrency](https://developers.google.com/gdata/docs/1.0/reference#Optimistic-concurrency)\nto work. \n\n```xml\n\u003c?xml version='1.0' encoding='UTF-8'?\u003e\n\u003cfeed xmlns='http://www.w3.org/2005/Atom'\n xmlns:gContact='http://schemas.google.com/contact/2008'\n xmlns:gd='http://schemas.google.com/g/2005'\n xmlns:batch='http://schemas.google.com/gdata/batch'\u003e\n \u003ccategory scheme='http://schemas.google.com/g/2005#kind'\n term='http://schemas.google.com/g/2008#contact' /\u003e\n \u003centry\u003e\n \u003cbatch:id\u003e1\u003c/batch:id\u003e\n \u003cbatch:operation type='insert' /\u003e\n \u003ccategory scheme='http://schemas.google.com/g/2005#kind'\n term='http://schemas.google.com/g/2008#contact'/\u003e\n \u003cgd:name\u003e\n \u003cgd:givenName\u003eFIRST_NAME\u003c/gd:fullName\u003e\n \u003cgd:familyName\u003eLAST_NAME\u003c/gd:fullName\u003e\n \u003c/gd:name\u003e\n \u003cgd:email rel='http://schemas.google.com/g/2005#home'\n address='EMAIL_ADDRESS' primary='true'/\u003e\n \u003c/entry\u003e\n \u003centry\u003e\n \u003cbatch:id\u003e2\u003c/batch:id\u003e\n \u003cbatch:operation type='insert' /\u003e\n \u003ccategory scheme='http://schemas.google.com/g/2005#kind'\n term='http://schemas.google.com/g/2008#contact'/\u003e\n \u003cgd:name\u003e\n \u003cgd:givenName\u003eFIRST_NAME\u003c/gd:fullName\u003e\n \u003cgd:familyName\u003eLAST_NAME\u003c/gd:fullName\u003e\n \u003c/gd:name\u003e\n \u003cgd:email rel='http://schemas.google.com/g/2005#home'\n address='EMAIL_ADDRESS'\n primary='true'/\u003e\n \u003c/entry\u003e\n\u003c/feed\u003e\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eFIRST_NAME\u003c/var\u003e: First name of the shared contact---for example, Alex.\n- \u003cvar translate=\"no\"\u003eLAST_NAME\u003c/var\u003e: The last name of the shared contact---for example, Kim.\n- \u003cvar translate=\"no\"\u003eEMAIL_ADDRESS\u003c/var\u003e: The preferred email address of the shared contact---for example, alk@gmail.com."]]