ภาพรวมคู่มือสําหรับนักพัฒนาซอฟต์แวร์
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
คําเตือน: หน้านี้เกี่ยวกับ API แบบเก่าของ Google ซึ่งก็คือ Google Data API โดยเกี่ยวข้องกับ API ที่แสดงอยู่ในไดเรกทอรี Google Data API เท่านั้น โดยหลาย API ถูกแทนที่ด้วย API ที่ใหม่กว่า สําหรับข้อมูลเกี่ยวกับ API ใหม่โดยเฉพาะ โปรดดูเอกสารประกอบของ API ใหม่ ดูข้อมูลเกี่ยวกับการให้สิทธิ์คําขอด้วย API ใหม่ได้ที่การตรวจสอบสิทธิ์และการให้สิทธิ์บัญชี Google
พันธกิจของ Google คือการจัดระเบียบข้อมูลสารสนเทศของโลก ทำให้ข้อมูลนั้นสามารถเข้าถึงได้และมีประโยชน์ต่อทุกคน ซึ่งรวมถึงการทําให้ข้อมูลเข้าถึงได้ในบริบทอื่นๆ ที่ไม่ใช่เว็บเบราว์เซอร์ และบริการที่สามารถเข้าถึงได้นอก Google
โปรโตคอลของ Google ช่วยให้นักพัฒนาแอปภายนอกเขียนแอปพลิเคชันใหม่ซึ่งช่วยให้ผู้ใช้ปลายทางเข้าถึงและอัปเดตข้อมูลที่จัดเก็บไว้โดยผลิตภัณฑ์จํานวนมากของ Google ได้ นักพัฒนาซอฟต์แวร์ภายนอกสามารถใช้ Google Data Protocol ได้โดยตรงหรือสามารถใช้ภาษาโปรแกรมที่รองรับจากไลบรารีของไคลเอ็นต์
ผู้ชม
เอกสารชุดนี้มีไว้สําหรับผู้ที่ต้องการทําความเข้าใจโปรโตคอลข้อมูลของ Google แม้ว่าคุณจะต้องการเขียนโค้ดที่ใช้ไลบรารีของไคลเอ็นต์เฉพาะภาษาเท่านั้น ชุดเอกสารนี้อาจเป็นประโยชน์หากคุณต้องการทําความเข้าใจสิ่งที่เกิดขึ้นภายใต้เลเยอร์นามธรรมของไลบรารีของไคลเอ็นต์
หากคุณกําลังมองหาคู่มือนักพัฒนาสําหรับ API หนึ่งๆ ให้ไปที่ไดเรกทอรี API ของ Google Data Protocol
หากต้องการเข้าถึง API ในภาษาโปรแกรมที่คุณชื่นชอบ ให้ไปที่หน้าดาวน์โหลดไลบรารีของไคลเอ็นต์
ที่มา
ผลิตภัณฑ์ของ Google จํานวนมาก เช่น ปฏิทินและสเปรดชีต มี API ที่ใช้โปรโตคอลของ Google Data คุณซึ่งเป็นนักพัฒนาแอปสามารถใช้ API เหล่านี้เพื่อเขียนแอปพลิเคชันไคลเอ็นต์ที่ช่วยให้ผู้ใช้ปลายทางเข้าถึงและจัดการข้อมูลที่เก็บรวบรวมในผลิตภัณฑ์ Google เหล่านั้นได้
หมายเหตุ: บางครั้งผลิตภัณฑ์ของ Google ที่มี API จะเรียกว่าบริการในเอกสารเหล่านี้และเอกสารอื่นๆ ที่เกี่ยวข้อง
หากคุณเขียนโค้ดที่ใช้ Google Data Protocol โดยตรง โค้ดดังกล่าวจะเข้าถึง API โดยใช้คําขอ HTTP เช่น GET
หรือ POST
สําหรับคําขอเหล่านี้ ข้อมูลที่จัดเก็บโดยผลิตภัณฑ์ของ Google จะรับส่งข้อมูลผ่านสายในรูปแบบฟีดข้อมูล ฟีดข้อมูลคือรายการที่มีโครงสร้างที่มีข้อมูลเท่านั้น ที่ผ่านมา รูปแบบฟีดหลักคือ AtomPub XML แต่ตอนนี้อยู่ในรูปแบบ JSON หรือ JavaScript Object Notation ในรูปแบบทางเลือกด้วย
หากคุณไม่ต้องการเขียนโค้ดที่ส่งคําขอ HTTP โดยตรง คุณสามารถเขียนโปรแกรมแอปพลิเคชันไคลเอ็นต์โดยใช้ภาษาโปรแกรมหนึ่งในชุดไลบรารีของไคลเอ็นต์ที่มีให้แทนได้ เมื่อคุณทําเช่นนี้ ไลบรารีของไคลเอ็นต์จะเป็นผู้จัดการรายละเอียดของคําขอ HTTP โดยคุณเขียนโค้ดตามแนวคิดโดยใช้วิธีการและคลาสเฉพาะภาษาจากไลบรารีของไคลเอ็นต์
โปรดดูเอกสารประกอบเฉพาะผลิตภัณฑ์เพื่อดูข้อมูลเพิ่มเติมเกี่ยวกับภาษาที่เฉพาะเจาะจงที่พร้อมใช้งานสําหรับ API หรือเวอร์ชัน API ที่คุณใช้
เวอร์ชันของโปรโตคอล
โปรโตคอลเวอร์ชัน 2.0 เทียบกับโปรโตคอลเวอร์ชัน 1.0
โปรโตคอล Google Data เวอร์ชันแรกได้รับการพัฒนาก่อนสรุปโปรโตคอลการเผยแพร่ข้อมูล โปรโตคอลข้อมูลเวอร์ชัน 2 เป็นไปตามมาตรฐาน AtomPub RFC 5023 อย่างเต็มรูปแบบ
Google Data Protocol เวอร์ชัน 2.0 ยังสนับสนุนสิ่งต่อไปนี้
- HTTP ETag มาตรฐานเว็บที่ช่วยให้แอปพลิเคชันไคลเอ็นต์ใช้ประโยชน์จากการแคช HTTP ได้ดีขึ้น บริการที่รวมอยู่ในไลบรารีของไคลเอ็นต์ที่รองรับโปรโตคอล v2.0 จะจัดการ ETag โดยอัตโนมัติ
- การตอบกลับบางส่วนและการอัปเดตบางส่วน (ทดลอง) ฟีเจอร์ที่ให้คุณส่งคําขอที่โอนข้อมูลน้อยลง เมื่อส่งคําขอเฉพาะข้อมูลที่คุณต้องการจริงๆ หรือส่งการอัปเดตที่มีข้อมูลที่คุณต้องการเปลี่ยนแปลงเท่านั้น แอปพลิเคชันไคลเอ็นต์จะมีประสิทธิภาพมากขึ้นด้วยการใช้ทรัพยากรเครือข่าย, CPU และหน่วยความจํา ปัจจุบัน คําตอบบางส่วนและการอัปเดตบางส่วนพร้อมใช้งานสําหรับบางผลิตภัณฑ์เท่านั้น โปรดดูเอกสารประกอบเฉพาะผลิตภัณฑ์เพื่อดูว่า API ของคุณรองรับหรือไม่
กําลังอัปเดตแอปพลิเคชัน
หาก API ที่คุณใช้นั้นสร้างบนโปรโตคอลเวอร์ชันล่าสุด ฟังก์ชันของโปรโตคอลเวอร์ชัน 2.0 จะรวมอยู่ในเอกสารประกอบ โดยทั่วไป เราขอแนะนําให้อัปเกรดแอปพลิเคชันไคลเอ็นต์เป็นเวอร์ชันล่าสุดที่พร้อมใช้งานสําหรับ API ของคุณ
การอัปเดตไคลเอ็นต์ที่ใช้ไลบรารีของไคลเอ็นต์
หากแอปพลิเคชันไคลเอ็นต์ของคุณใช้ไลบรารีของไคลเอ็นต์ เช่น ไลบรารีของไคลเอ็นต์ Java หรือไลบรารีของไคลเอ็นต์ .NET อาจมี API เวอร์ชันที่รองรับฟีเจอร์โปรโตคอล v2.0 หากต้องการทราบข้อมูล โปรดดูเอกสารประกอบ API สําหรับผลิตภัณฑ์ของ Google ที่คุณใช้เพื่อพิจารณาว่าข้อมูลทั้ง 2 อย่างนี้เป็นจริงหรือไม่
- มี API เวอร์ชันที่รองรับฟีเจอร์ Google Data Protocol v2.0
- ไลบรารีของไคลเอ็นต์ที่คุณใช้ยังรองรับ API เวอร์ชันดังกล่าวด้วย
หากไลบรารีของไคลเอ็นต์รองรับและคุณต้องการอัปเดตแอปพลิเคชันที่มีอยู่ เพียงดาวน์โหลดและใช้ไลบรารีของไคลเอ็นต์เวอร์ชันล่าสุด โค้ดทั้งหมดยังคงใช้งานได้ และไลบรารีของไคลเอ็นต์จะดูแลการเปลี่ยนแปลงโปรโตคอล v2.0 ในกลไกการทํางาน
กําลังอัปเดตไคลเอ็นต์ HTTP ดิบ
หากเขียนแอปพลิเคชันไคลเอ็นต์โดยใช้โปรโตคอลข้อมูลของ Google โดยตรง คุณจะต้องทําการเปลี่ยนแปลงต่อไปนี้
- คําขอเวอร์ชันที่ไม่ใช่ค่าเริ่มต้น เพิ่มส่วนหัวเวอร์ชัน HTTP (
GData-Version: X.0
) ลงในคําขอ HTTP ทั้งหมดที่คุณส่ง โดย X
คือ API เวอร์ชันที่รองรับฟีเจอร์ Google Data Protocol v2.0 หรือเพิ่มพารามิเตอร์การค้นหา (v=X.0
) ลงใน URL ของทุกคําขอ โดยที่ X
เป็น API เวอร์ชันที่ถูกต้องอีกครั้ง หากคุณไม่ระบุเวอร์ชันที่ใหม่กว่า ระบบจะส่งคําขอไปยัง API เวอร์ชันแรกสุดที่รองรับโดยค่าเริ่มต้น
- การเกิดขึ้นพร้อมกันในแง่ดี หากใช้ API เวอร์ชันที่รองรับการเกิดขึ้นพร้อมกันอย่างเหมาะสม คุณอาจต้องเปลี่ยนการอัปเดตและลบโค้ดเพื่อใช้ ETag โปรดอ่านข้อมูลเพิ่มเติมที่ส่วน ETag ของเอกสารประกอบข้อมูลอ้างอิงของโปรโตคอลข้อมูลของ Google และอ่านส่วน "อัปเดตและลบ" ในคู่มือสําหรับนักพัฒนาซอฟต์แวร์เกี่ยวกับโปรโตคอลที่แอปพลิเคชันไคลเอ็นต์ของคุณใช้
- แก้ไข URI ด้วยตนเอง หากไคลเอ็นต์ติดตามการแก้ไขด้วยตนเองหรือ URI สําหรับฟีดหรือรายการ โปรดทราบว่า URI เหล่านั้นอาจเปลี่ยนแปลง หากต้องการ URI ใหม่ ให้ขอรายการอีกครั้งโดยใช้ URI เก่า แต่ทําเครื่องหมายคําขอเป็นคําขอเวอร์ชัน X.0 โดยที่ X คือ API เวอร์ชันที่รองรับฟีเจอร์ Google Data Protocol v2.0 เซิร์ฟเวอร์จะส่งคืนรายการใหม่ รวมถึง URI ใหม่ ซึ่งคุณสามารถจัดเก็บแทนที่รายการเก่าได้
- URI เนมสเปซ หากไคลเอ็นต์จัดเก็บ URI เนมสเปซของ Google Data Protocol API ไว้ในเครื่องของคุณเอง หรือฮาร์ดโค้ดไว้ คุณจะต้องอัปเดตสิ่งต่อไปนี้
- เนมสเปซเนมสเปซ AtomPub (คํานําหน้า
app
) เปลี่ยนจาก http://purl.org/atom/app
เป็น http://www.w3.org/2007/app
- เนมสเปซใน SearchSearch (คํานําหน้า
openSearch
) เปลี่ยนจาก http://a9.com/-/spec/opensearchrss/1.0/
เป็น http://a9.com/-/spec/opensearch/1.1/
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2023-03-01 UTC
[[["เข้าใจง่าย","easyToUnderstand","thumb-up"],["แก้ปัญหาของฉันได้","solvedMyProblem","thumb-up"],["อื่นๆ","otherUp","thumb-up"]],[["ไม่มีข้อมูลที่ฉันต้องการ","missingTheInformationINeed","thumb-down"],["ซับซ้อนเกินไป/มีหลายขั้นตอนมากเกินไป","tooComplicatedTooManySteps","thumb-down"],["ล้าสมัย","outOfDate","thumb-down"],["ปัญหาเกี่ยวกับการแปล","translationIssue","thumb-down"],["ตัวอย่าง/ปัญหาเกี่ยวกับโค้ด","samplesCodeIssue","thumb-down"],["อื่นๆ","otherDown","thumb-down"]],["อัปเดตล่าสุด 2023-03-01 UTC"],[[["\u003cp\u003eThe Google Data Protocol enables external developers to build applications that access and update data stored in various Google products.\u003c/p\u003e\n"],["\u003cp\u003eDevelopers can use the protocol directly via HTTP requests or leverage client libraries for supported programming languages.\u003c/p\u003e\n"],["\u003cp\u003eGoogle Data Protocol v2.0, aligned with AtomPub RFC 5023, introduces features like HTTP ETags, Partial Response, and Partial Update for enhanced efficiency.\u003c/p\u003e\n"],["\u003cp\u003eUpgrading to Protocol v2.0 may require updating client applications to handle changes related to version requests, optimistic concurrency, URIs, and namespaces.\u003c/p\u003e\n"],["\u003cp\u003eRefer to specific product documentation and the Google Data APIs directory for API details and compatibility.\u003c/p\u003e\n"]]],[],null,["# Developer's Guide Overview\n\n**Warning** : This page is about Google's older APIs, the Google Data APIs; it's relevant only to the APIs that are listed in the [Google Data APIs directory](/gdata/docs/directory), many of which have been replaced with newer APIs. For information about a specific new API, see the new API's documentation. For information about authorizing requests with a newer API, see [Google Accounts Authentication and Authorization](/accounts).\n\nGoogle's mission is to organize the world's information and make it universally accessible and useful. This includes making information accessible in contexts other than a web browser and accessible to services outside of Google.\n\nThe Google Data Protocol provides a secure means for external developers to write new applications that let end users access and update the data stored by many Google products. External developers can use the Google Data Protocol directly, or they can use any of the supported programming languages provided by the client libraries. \n\nAudience\n========\n\nThis set of documents is intended for anyone who wants to understand Google Data Protocol. Even if you just want to write code that uses the language-specific [client libraries](/gdata/docs/client-libraries), this document set can be helpful if you want to understand what's going on beneath the client-library abstraction layer.\n\nIf you're looking for the Developer's Guide for a specific API, visit the Google Data Protocol [API Directory](/gdata/docs/directory).\n\nIf you want to access an API in your favorite programming language, visit the [Client Libraries](/gdata/docs/client-libraries) download page.\n\nBackground\n==========\n\nA number of Google products, such as Calendar and Spreadsheets, provide APIs that are based on the Google Data Protocol. You, the developer, can use these APIs to write client applications that give end users new ways to access and manipulate the data they store in those Google products.\n\n**Note:** Google products that provide APIs are sometimes referred to as *services* in these and other related documents.\n\nIf you write code that uses the Google Data Protocol directly, it accesses the API using HTTP requests like `GET` or `POST`. With these requests, data stored by the Google product is transferred back and forth over the wire in the form of data feeds. The data feeds are simply structured lists that contain the data. Historically, the primary feed format has been AtomPub XML, but now JSON, or JavaScript Object Notation, is also available as an [alternate format](/gdata/docs/json).\n\nIf you prefer not to write code that makes HTTP requests directly, you can instead program your client application using one of the programming languages available in the set of client libraries provided. When you do this, the details of the HTTP requests are handled by the client library; you write your code at a more conceptual level using the language-specific methods and classes provided by the client library.\n\nRefer to the product-specific documentation for more information about the particular languages available for the API, or API version, you are using.\n\nVersions of the protocol\n========================\n\n### Protocol Version 2.0 vs. Protocol Version 1.0\n\nThe first version of the Google Data Protocol was developed before the Atom Publishing Protocol was finalized. The second version of the Google Data Protocol is fully compliant with the AtomPub [RFC 5023](http://www.rfc-editor.org/rfc/rfc5023.txt) standard.\n\nThe Google Data Protocol Version 2.0 also includes support for:\n\n- [HTTP ETags](/gdata/docs/2.0/reference#ResourceVersioning). A web standard that helps your client applications make better use of HTTP caching. The services included in the client libraries that support Protocol v2.0 handle ETags automatically.\n- [Partial Response](/gdata/docs/2.0/reference#PartialResponse) and [Partial Update](/gdata/docs/2.0/reference#PartialUpdate) (Experimental). Features that let you make requests that transfer less data. By requesting only the information that you actually need, or by sending updates that include only the data that you actually want to change, your client application can be much more efficient in its use of network, CPU, and memory resources. Currently, partial response and partial update are available only for some products; see the product-specific documentation to find out if your API supports it.\n\n### Updating your application\n\nIf the API you are using was built upon the latest version of the protocol, then the Protocol v2.0 functionality is included in its documentation. In general, we recommend that you upgrade your client application to the latest version available for your API.\n\n#### Updating a client-library-based client\n\nIf your client application uses a client library, such as the Java client library or the .NET client library, it may contain a version of the API that supports Protocol v2.0 features. To find out, refer to the API documentation for the Google product you are using to find out if both of the following are true:\n\n- There is an API version that supports Google Data Protocol v2.0 features.\n- The client library you are using also supports that API version.\n\nIf the client library supports it and you want to update your existing application, just download and use the latest version of the client library. All of your code still works, and the client library takes care of the Protocol v2.0 changes under the hood.\n\n#### Updating a raw HTTP client\n\nIf you wrote your client application using the Google Data Protocol directly, you need to make these changes:\n\n- **Non-default version requests.** Add an HTTP version header (`GData-Version: `*X*`.0`) to every HTTP request you send, where *`X`* is the version of the API that supports Google Data Protocol v2.0 features. Alternatively, add a query parameter (`v=`*X*`.0`) to the URL of every request, where *`X`* is, again, the correct version of the API. If you do not specify a later version, your requests are sent to the earliest supported version of the API by default.\n- **Optimistic concurrency.** If you were using a version of an API that supported optimistic concurrency, you may need to change your update and delete code to use ETags. For more information, read the [ETags section](/gdata/docs/2.0/reference#ResourceVersioning) of the Google Data Protocol reference documentation, and read the Update and Delete sections of the Protocol developer's guide for the service your client application is using.\n- **Self or edit URIs.** If your client keeps track of self or edit URIs for feeds or entries, note that those URIs may have changed. To get the new URI, re-request the item using the old URI, but mark the request as a version *X* .0 request, where *X* is the version of the API that supports Google Data Protocol v2.0 features. The server returns the new representation of the entry, including the new URIs, which you can store in place of the old ones.\n- **Namespace URIs.** If your client stores Google Data Protocol API namespace URIs locally, or has them hard-coded, you'll need to update them:\n - The AtomPub namespace (prefix `app`) has been changed from `http://purl.org/atom/app` to `http://www.w3.org/2007/app`.\n - The OpenSearch namespace (prefix `openSearch`) has been changed from `http://a9.com/-/spec/opensearchrss/1.0/` to `http://a9.com/-/spec/opensearch/1.1/`."]]