Google Data API 示例
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
警告:此页面介绍的是 Google 的旧版 API(即 Google Data API),仅适用于Google Data API 目录中列出的 API,其中许多 API 已被更新的 API 取代。如需了解特定新 API,请参阅相应新 API 的文档。如需了解如何使用较新的 API 授权请求,请参阅 Google 账号身份验证和授权。
本页面提供指向示例代码的链接以及有关示例代码的信息。
目录
- JavaScript 示例
- JSON 示例
- 小工具示例
- Java 示例
- .NET 示例
- 其他语言
JavaScript 示例
JavaScript 客户端库可用于从 Web 浏览器与 Base Data API、Blogger Data API、Calendar Data API、Contacts Data API 和 Finance Data API 进行交互。
注意:本部分中之前的示例已被移除,因为它们依赖于不再可用的 API 和/或身份验证方法。
JSON 示例
这些是实时示例;点击即可查看。如需了解详情,请参阅将 JSON 与 Google Data API 搭配使用。
Google 日历
- 日历中即将进行的活动
- 此示例演示了如何使用 Calendar Data API 提供的 JSON 输出格式在网页上显示 Google 日历中即将举行的活动列表。
Blogger
- Blogger 近期发布的帖子
- 此示例演示了如何使用 Blogger Data API 提供的 JSON 输出格式显示托管在 Blogger Beta 上的博客中的近期帖子列表。
电子表格
- 读取 Google 电子表格数据
- 此示例演示了如何使用 Spreadsheet Data API 提供的 JSON 输出格式在网页上显示 Google 电子表格中的数据。
小工具示例
如需详细了解如何创建 Google Data API 插件,请参阅创建 Google Data 插件或完整的编写 OAuth 插件文档。
- Blogger 小工具
- YouTube 小工具
Java 示例
与客户端库捆绑的示例
您可以在可下载的 Java 客户端库软件包中找到这些示例。如需了解详情,请参阅 Java 客户端库开发者指南,或下载 Java 客户端库。
- java/sample/authsub/
- 使用 Java Servlet 实现的 GData AuthSub 代理;通过该代理访问数据的 JavaScript 客户端示例。
- java/sample/calendar/
- 一个简单的客户端,可对 Google 日历执行多项硬编码操作。
- java/sample/codesarch/
- 用于查询 Google Code Search Data API 的命令行客户端。
- java/sample/spreadsheet/
- 使用 Google Spreadsheet API 的示例应用。
- java/sample/appsforyourdomain/
- 使用 G Suite API 的示例应用。
- java/sample/blogger/
- 使用 Blogger API 的示例应用。
- java/sample/contacts/
- 使用 Google Contacts API 的示例应用。
- java/sample/docs/
- 使用 Google Doclist API 的示例应用。
- java/sample/gbase/
- 使用 Google Base API 的示例应用。
- java/sample/photos/
- 使用 Picasa Web Albums API 的示例应用。
- java/sample/sidewiki/
- 使用 Google Sidewiki API 的示例应用。
- java/sample/webmastertools/
- 使用 Webmaster API 的示例应用。
- java/sample/youtube/
- 使用 YouTube API 的示例应用。
- YouTube 示例 ASP 页面
- 使用客户端库的视频搜索和上传示例。
.NET 示例
与客户端库捆绑的示例
您可以在可下载的 .NET 客户端库软件包中找到这些示例。如需了解详情,请参阅 .NET 客户端库开发者指南,或下载 .NET 客户端库。
- clients/cs/samples/blogger/
- 使用 Blogger API 的示例应用。
- clients/cs/samples/calendar/
- 使用 Google Calendar Data API 的示例应用。
- clients/cs/samples/spreadsheets/
- 使用 Google Spreadsheet API 的示例应用。
- clients/cs/samples/DocListUploader/
- 将文档上传到 Google 文档。
- clients/cs/samples/DocListExporter/
- 以各种格式导出 Google 文档。
- clients/cs/samples/PhotoBrowser/
- 使用 Picasa Web Albums API 的示例应用。
- clients/cs/samples/YouTubeSample/
- 使用 YouTube API 的示例应用。
- clients/cs/samples/appsforyourdomain/
- 使用 G Suite API 的示例应用。
其他示例
- “通讯录更新程序”
- 一个 WPF 示例,演示了如何使用 Contacts API 读取和更新联系人。
您还可以下载 .zip 文件。
- Google 文档 PDF 连接器
- 将 PDF 文件串联在一起,并将结果上传到 Google 文档。
您还可以下载 .zip 文件。
其他语言
C++
- Documents List API 示例
- 允许用户查看、上传、删除和搜索其 Google 文档、电子表格、演示文稿和文件夹。此示例还通过列出具有读/写权限的用户来演示 API 的 ACL 功能。
Ruby
- DocList 管理器
- Ruby on Rails 示例,允许用户查看和导出文档。
返回页首
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-26。
[null,null,["最后更新时间 (UTC):2025-07-26。"],[[["\u003cp\u003eThis page focuses on Google's older Google Data APIs and provides links to relevant documentation for newer APIs.\u003c/p\u003e\n"],["\u003cp\u003eThe page offers various code samples in JavaScript, JSON, Gadget, Java, .NET, and other languages to showcase interactions with the APIs.\u003c/p\u003e\n"],["\u003cp\u003eMany previously available JavaScript samples have been removed due to reliance on outdated APIs or authentication methods.\u003c/p\u003e\n"],["\u003cp\u003eUsers can find bundled sample code within the downloadable Java and .NET client library packages.\u003c/p\u003e\n"],["\u003cp\u003eGoogle provides documentation and resources for creating Google Data API gadgets and using JSON with Google Data APIs.\u003c/p\u003e\n"]]],[],null,["# Google Data APIs Samples\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\nThis page provides links and information about sample code.\n\nContents\n--------\n\n1. [JavaScript samples](#JavaScript)\n2. [JSON samples](#JSON)\n3. [Gadget samples](#Gadgets)\n4. [Java samples](#Java)\n5. [.NET samples](#NET)\n6. [Other languages](#OTHERLANGS)\n\nJavaScript samples\n------------------\n\nThe [JavaScript client library](/gdata/docs/js)\ncan be used from web browsers to interact with the [Base Data API](/base), [Blogger Data API](/blogger/docs/1.0/developers_guide_js),\n[Calendar Data API](/google-apps/calendar/v1/developers_guide_javascript), [Contacts Data API](/google-apps/contacts/v1/developers_guide_js), and\n[Finance Data API](/finance/docs/1.0/developers_guide_js).\n\n**Note**: The samples that were previously in this section have been removed because they relied on APIs and/or authentication methods that are no longer available.\n\nJSON samples\n------------\n\nThese are live samples; click to view them. For more information, see [Using JSON with Google Data APIs](/gdata/json).\n\n### Google Calendar\n\n[Upcoming events from Calendar](/gdata/samples/cal_sample)\n: This sample demonstrates displaying a list of upcoming calendar events from a Google Calendar on a web page using the JSON output format provided by the Calendar Data API.\n\n### Blogger\n\n[Recent posts from Blogger](/gdata/samples/blogger_sample)\n: This sample demonstrates displaying a list of recent posts from a blog hosted on Blogger Beta using the JSON output format provided by the Blogger Data API.\n\n### Spreadsheets\n\n[Reading Google Spreadsheets data](/gdata/samples/spreadsheet_sample)\n: This sample demonstrates displaying data from a Google Spreadsheet on a web page using the JSON output format provided by the Spreadsheet Data API.\n\nGadget samples\n--------------\n\nFor more information on creating Google Data API gadgets, see [Creating a Google Data Gadget](/gdata/articles/gdata_gadgets) or the full [Writing OAuth Gadgets](/gadgets/docs/oauth) documentation.\n\n[Blogger gadget](http://code.google.com/p/gdata-samples/source/browse/trunk/gadgets/blogger/blogger_gadget.xml)\n[YouTube gadget](http://gadget-doc-examples.googlecode.com/svn/trunk/opensocial-gadgets/oauth-test.xml)\n\nJava samples\n------------\n\n### Samples bundled with the client library\n\nThese samples can be found in the downloadable Java client library\npackage. For more information, see the [Java\nclient library developer's guide](/gdata/client-java), or [download the Java client library](//code.google.com/p/gdata-java-client/downloads/list).\n\n[java/sample/authsub/](//code.google.com/p/gdata-java-client/source/browse/trunk/java/sample/authsub)\n: GData AuthSub proxy, implemented using Java servlets; sample JavaScript client that accesses data through the proxy.\n\n[java/sample/calendar/](//code.google.com/p/gdata-java-client/source/browse/trunk/java/sample/calendar)\n: Simple client that performs several hardwired manipulations on a Google Calendar.\n\n[java/sample/codesarch/](//code.google.com/p/gdata-java-client/source/browse/trunk/java/sample/codesearch)\n: Command line client to query the Google Code Search data API.\n\n[java/sample/spreadsheet/](//code.google.com/p/gdata-java-client/source/browse/trunk/java/sample/spreadsheet)\n: Sample apps using Google Spreadsheet API.\n\n[java/sample/appsforyourdomain/](//code.google.com/p/gdata-java-client/source/browse/trunk/java/sample/appsforyourdomain)\n: Sample apps using G Suite API.\n\n[java/sample/blogger/](//code.google.com/p/gdata-java-client/source/browse/trunk/java/sample/blogger)\n: Sample apps using Blogger API.\n\n[java/sample/contacts/](//code.google.com/p/gdata-java-client/source/browse/trunk/java/sample/contacts)\n: Sample apps using Google Contacts API.\n\n[java/sample/docs/](//code.google.com/p/gdata-java-client/source/browse/trunk/java/sample/docs)\n: Sample apps using Google Doclist API.\n\n[java/sample/gbase/](//code.google.com/p/gdata-java-client/source/browse/trunk/java/sample/gbase)\n: Sample apps using Google Base API.\n\n[java/sample/photos/](//code.google.com/p/gdata-java-client/source/browse/trunk/java/sample/photos)\n: Sample apps using Picasa Web Album API.\n\n[java/sample/sidewiki/](//code.google.com/p/gdata-java-client/source/browse/trunk/java/sample/sidewiki)\n: Sample apps using Google Sidewiki API.\n\n[java/sample/webmastertools/](//code.google.com/p/gdata-java-client/source/browse/trunk/java/sample/webmastertools)\n: Sample apps using Webmaster API.\n\n[java/sample/youtube/](//code.google.com/p/gdata-java-client/source/browse/trunk/java/sample/youtube)\n: Sample apps using YouTube API.\n\n[YouTubeSample ASP page](http://google-gdata.googlecode.com/svn/trunk/clients/cs/samples/YouTubeSample/)\n: Video search and upload sample using the client library.\n\n.NET samples\n------------\n\n### Samples bundled with the client library\n\nThese samples can be found in the downloadable .NET client library package. For more information, see the [.NET client library developer's guide](/gdata/client-cs), or [download the .NET client library](//code.google.com/p/google-gdata).\n\n[clients/cs/samples/blogger/](//code.google.com/p/google-gdata/source/browse/trunk/clients/cs/samples/blogger)\n: Sample apps using Blogger API.\n\n[clients/cs/samples/calendar/](//code.google.com/p/google-gdata/source/browse/trunk/clients/cs/samples/calendar)\n: Sample apps using Google Calendar Data API.\n\n[clients/cs/samples/spreadsheets/](//code.google.com/p/google-gdata/source/browse/trunk/clients/cs/samples/spreadsheets)\n: Sample apps using Google Spreadsheet API.\n\n[clients/cs/samples/DocListUploader/](//code.google.com/p/google-gdata/source/browse/trunk/clients/cs/samples/DocListUploader)\n: Uploads documents to Google Docs.\n\n[clients/cs/samples/DocListExporter/](//code.google.com/p/google-gdata/source/browse/trunk/clients/cs/samples/DocListExporter)\n: Exports Google Documents in various formats.\n\n[clients/cs/samples/PhotoBrowser/](//code.google.com/p/google-gdata/source/browse/trunk/clients/cs/samples/PhotoBrowser)\n: Sample apps using Picasa Web Album API.\n\n[clients/cs/samples/YouTubeSample/](//code.google.com/p/google-gdata/source/browse/trunk/clients/cs/samples/YouTubeSample)\n: Sample apps using YouTube API.\n\n[clients/cs/samples/appsforyourdomain/](//code.google.com/p/google-gdata/source/browse/trunk/clients/cs/samples/appsforyourdomain)\n: Sample apps using G Suite API.\n\n### Other examples\n\n[Contacts Updater](//code.google.com/p/gdata-samples/source/browse/#svn/trunk/contacts/ContactsUpdater)\n: A WPF sample that demonstrates how to read and update your contacts using the Contacts API.\n A [.zip file](http://gdata-samples.googlecode.com/svn/trunk/contacts/ContactsUpdater/ContactsUpdater.zip) is also available.\n\n[Google Docs PDF Concatenator](//code.google.com/p/gdata-samples/source/browse/#svn/trunk/doclist/PdfConcatenate)\n: Concatenates PDF files together and uploads the result to Google Docs.\n A [.zip file](http://gdata-samples.googlecode.com/files/PdfConcatenate.zip) is also available.\n\nOther languages\n---------------\n\n### C++\n\n[Documents List API sample](//code.google.com/p/gdata-cpp-util/source/browse/trunk/doclist_sample.cc)\n: Allows users to view, upload, delete, and search their Google documents, spreadsheets, presentations, and folders. This sample\n also demonstrates the API's ACL functionality by listing the users who have read/write permissions.\n\n### Ruby\n\n[DocList Manager](//code.google.com/p/gdata-samples/source/browse/#svn/trunk/doclist/DocListManager)\n: Ruby on Rails sample that allows users to view and export documents.\n\n[Back to top](#top)"]]