ตัวอย่างง่ายๆ ในการเรียกฟีด JSON จาก API ข้อมูลสเปรดชีต
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
คําเตือน: หน้านี้เกี่ยวกับ API แบบเก่าของ Google ซึ่งก็คือ Google Data API โดยเกี่ยวข้องกับ API ที่แสดงอยู่ในไดเรกทอรี Google Data API เท่านั้น โดยหลาย API ถูกแทนที่ด้วย API ที่ใหม่กว่า สําหรับข้อมูลเกี่ยวกับ API ใหม่โดยเฉพาะ โปรดดูเอกสารประกอบของ API ใหม่ ดูข้อมูลเกี่ยวกับการให้สิทธิ์คําขอด้วย API ใหม่ได้ที่การตรวจสอบสิทธิ์และการให้สิทธิ์บัญชี Google
บทนำ
ตัวอย่างนี้สาธิตการแสดงรายการหรือฟีดเซลล์สําหรับเวิร์กชีตหนึ่งๆ ในสเปรดชีตโดยใช้รูปแบบเอาต์พุต JSON ที่ได้จาก API ข้อมูลสเปรดชีต ซึ่งจะช่วยให้คุณค้นหารายการสาธารณะหรือฟีดเซลล์ของสเปรดชีตเพื่อรับรายการที่ได้เป็นออบเจ็กต์ JSON ได้ หากต้องการใช้ฟีด JSON ใหม่ ให้สร้างองค์ประกอบสคริปต์ที่มีค่า src
http://spreadsheets.google.com/feeds/feed/key/worksheet/public/basic?alt=json-in-script&callback=myFunc
โดยที่ feed
คือประเภทของฟีด key
คือคีย์ของสเปรดชีตที่ต้องการเรียก worksheet
คือตัวระบุตามตําแหน่งที่ไม่ซ้ํากันหรือข้อมูลของเวิร์กชีต และ myFunc
คือชื่อของฟังก์ชันเรียกกลับที่ส่งผ่านออบเจ็กต์ JSON ดูข้อมูลเพิ่มเติมเกี่ยวกับการรองรับเอาต์พุต JSON สําหรับ Google Data API ได้ที่เอกสารประกอบการสนับสนุนเอาต์พุต JSON
หมายเหตุ: การรับฟีดที่ไม่มีการตรวจสอบสิทธิ์จะใช้ได้กับสเปรดชีตที่เผยแพร่เท่านั้น
หมายเหตุ: ฟีดประเภทอื่นๆ รวมถึงค่าระดับการเข้าถึงและการฉายภาพอาจใช้กับการรองรับเอาต์พุต JSON โปรดดูข้อมูลเพิ่มเติมเกี่ยวกับฟีดประเภทอื่นๆ รวมถึงค่าระดับการเข้าถึงและการฉายภาพในเอกสารประกอบ ไว้ที่สเปรดชีต Data API
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2023-03-01 UTC
[null,null,["อัปเดตล่าสุด 2023-03-01 UTC"],[],[],null,["# Simple example of retrieving JSON feeds from Spreadsheets Data API\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| Version v4 of the [Google Sheets API](/sheets) is now available! This [migration guide](/sheets/guides/migration) shows how to update applications to use v4.\n\n### Introduction\n\nThis sample demonstrates displaying a list or cells feed for a particular worksheet in a spreadsheet using the JSON output format provided by the Spreadsheets Data API. This allows you to query a spreadsheet's public list or cell feed and get the resulting entries returned as JSON objects. To use the new JSON feed, create a script element whose `src` value is\n\u003e `http://spreadsheets.google.com/feeds/`**feed** `/`**key** `/`**worksheet** `/public/basic?alt=json-in-script&callback=`**myFunc**\n\nwhere **`feed`** is the type of feed, **`key`** is the key of the spreadsheet you want to retrieve, the **`worksheet`** is the positional or unique identifier of the worksheet, and **`myFunc`** is the name of your callback function that is passed the JSON object. For more information on JSON output support for Google Data APIs please see our [JSON output support documentation](/gdata/json).\n\n**Note:** Retrieving a feed without authentication is only supported for published spreadsheets.\n\n**Note:** Other feed types and visibility and projection values may be used with JSON output support. For more information on other feed types, and visibility and projection values please see the [Spreadsheets Data API](/google-apps/spreadsheets) documentation.\n\n### Demo\n\nSpreadsheet: http://spreadsheets.google.com/feeds/ list cells / / /public/values OK"]]