Programmer's Reference Guide
| Google Calendar の使用法 |
Google Documents List Data API の使用法
Google Documents List Data API は、 クライアントアプリケーションから Google Documents にドキュメントをアップロードしたり、 ドキュメントの一覧を Google Data API ("GData") 形式のフィードで取得したりするためのものです。 クライアントアプリケーションからユーザのドキュメントの一覧をリクエストしたり、 ドキュメントの中身を問い合わせたりすることができます。
Google Documents List API についての詳細は » http://code.google.com/apis/documents/overview.html を参照ください。
ドキュメントの一覧の取得
特定のユーザの Google Documents の一覧を取得するには、docs サービスの
getDocumentListFeed メソッドを使用します。
このサービスは Zend_Gdata_Docs_DocumentListFeed
オブジェクトを返します。
その中には、認証済みユーザに関連付けられたドキュメントの一覧が含まれます。
- $service = Zend_Gdata_Docs::AUTH_SERVICE_NAME;
- $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
- $docs = new Zend_Gdata_Docs($client);
- $feed = $docs->getDocumentListFeed();
結果として得られる Zend_Gdata_Docs_DocumentListFeed
オブジェクトが、サーバからの応答を表します。
このフィードには Zend_Gdata_Docs_DocumentListEntry
オブジェクトの一覧 ($feed->entries) が含まれ、
それぞれがひとつの Google Document を表します。
ドキュメントのアップロード
新しい Google Document を作成するには、 ワープロ文書やスプレッドシート、あるいはプレゼンテーションをアップロードします。 この例はインタラクティブなサンプル Docs.php で、これはライブラリに同梱されています。 これは、ファイルをアップロードした後で、 サーバからその結果の情報を取得して表示するものです。
- /**
- * Upload the specified document
- *
- * @param Zend_Gdata_Docs $docs The service object to use for communicating
- * with the Google Documents server.
- * @param boolean $html True if output should be formatted for display in a
- * web browser.
- * @param string $originalFileName The name of the file to be uploaded. The
- * MIME type of the file is determined from the extension on this file
- * name. For example, test.csv is uploaded as a comma seperated volume
- * and converted into a spreadsheet.
- * @param string $temporaryFileLocation (optional) The file in which the
- * data for the document is stored. This is used when the file has been
- * uploaded from the client's machine to the server and is stored in
- * a temporary file which does not have an extension. If this parameter
- * is null, the file is read from the originalFileName.
- */
- function uploadDocument($docs, $html, $originalFileName,
- $temporaryFileLocation) {
- $fileToUpload = $originalFileName;
- if ($temporaryFileLocation) {
- $fileToUpload = $temporaryFileLocation;
- }
- // Upload the file and convert it into a Google Document. The original
- // file name is used as the title of the document and the MIME type
- // is determined based on the extension on the original file name.
- $newDocumentEntry = $docs->uploadFile($fileToUpload, $originalFileName,
- null, Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI);
- echo "New Document Title: ";
- if ($html) {
- // Find the URL of the HTML view of this document.
- $alternateLink = '';
- foreach ($newDocumentEntry->link as $link) {
- if ($link->getRel() === 'alternate') {
- $alternateLink = $link->getHref();
- }
- }
- // Make the title link to the document on docs.google.com.
- echo "<a href=\"$alternateLink\">\n";
- }
- }
ドキュメントのフィードの検索
ドキュメントの一覧を検索するには、» 標準的な Google Data API クエリパラメータ を使用します。 カテゴリを使用して、ドキュメントの種類 (ワープロ文書、 スプレッドシート) を絞り込みます。 フルテキストのクエリ文字列を使用して、ドキュメントの全文検索を行います。 ドキュメントの一覧に固有のパラメータについての詳細な情報は、 » Documents List Data API リファレンスガイド を参照ください。
ワープロ文書の一覧の取得
指定した型のすべてのドキュメントを含むフィードを取得することもできます。 たとえば、ワープロ文書の一覧を取得するには、 次のようなカテゴリクエリを使用します。
- $feed = $docs->getDocumentListFeed(
- 'http://docs.google.com/feeds/documents/private/full/-/document');
スプレッドシートの一覧の取得
Google Spreadsheets の一覧を取得するには、 次のようなカテゴリクエリを使用します。
- $feed = $docs->getDocumentListFeed(
- 'http://docs.google.com/feeds/documents/private/full/-/spreadsheet');
テキストクエリの実行
ドキュメントの中身を検索するには、リクエスト内で Zend_Gdata_Docs_Query を使用します。 クエリオブジェクトを使用してクエリ URI を組み立て、 検索する単語をパラメータとして渡します。 これは、ある文字列を含むドキュメントを一覧から探すクエリの例です。
- $docsQuery = new Zend_Gdata_Docs_Query();
- $docsQuery->setQuery($query);
- $feed = $client->getDocumentListFeed($docsQuery);
| Google Calendar の使用法 |
Select a Version
Languages Available
Components
Search the Manual
Navigation
- プログラマ向けリファレンスガイド
- プログラマ向けリファレンスガイド
- Zend_Gdata
- 導入
- AuthSub による認証
- Using the Book Search Data API
- ClientLogin による認証
- Google Calendar の使用法
- Google Documents List Data API の使用法
- Using Google Health
- Google Spreadsheets の使用法
- Google Apps Provisioning の使用法
- Google Base の使用法
- Picasa Web Albums の使用法
- YouTube Data API の使用法
- Gdata の例外処理
