Zend_Gdata_Docs.xml 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <!-- EN-Revision: 15103 -->
  4. <sect1 id="zend.gdata.docs">
  5. <title>Google Documents List Data API の使用法</title>
  6. <para>
  7. Google Documents List Data API は、
  8. クライアントアプリケーションから Google Documents
  9. にドキュメントをアップロードしたり、
  10. ドキュメントの一覧を Google Data API ("GData")
  11. 形式のフィードで取得したりするためのものです。
  12. クライアントアプリケーションからユーザのドキュメントの一覧をリクエストしたり、
  13. ドキュメントの中身を問い合わせたりすることができます。
  14. </para>
  15. <para>
  16. Google Documents List API についての詳細は
  17. <ulink url="http://code.google.com/apis/documents/overview.html">http://code.google.com/apis/documents/overview.html</ulink>
  18. を参照ください。
  19. </para>
  20. <sect2 id="zend.gdata.docs.listdocuments">
  21. <title>ドキュメントの一覧の取得</title>
  22. <para>
  23. 特定のユーザの Google Documents の一覧を取得するには、docs サービスの
  24. <code>getDocumentListFeed</code> メソッドを使用します。
  25. このサービスは <classname>Zend_Gdata_Docs_DocumentListFeed</classname>
  26. オブジェクトを返します。
  27. その中には、認証済みユーザに関連付けられたドキュメントの一覧が含まれます。
  28. </para>
  29. <programlisting role="php"><![CDATA[
  30. $service = Zend_Gdata_Docs::AUTH_SERVICE_NAME;
  31. $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
  32. $docs = new Zend_Gdata_Docs($client);
  33. $feed = $docs->getDocumentListFeed();
  34. ]]>
  35. </programlisting>
  36. <para>
  37. 結果として得られる <classname>Zend_Gdata_Docs_DocumentListFeed</classname>
  38. オブジェクトが、サーバからの応答を表します。
  39. このフィードには <classname>Zend_Gdata_Docs_DocumentListEntry</classname>
  40. オブジェクトの一覧 (<code>$feed->entries</code>) が含まれ、
  41. それぞれがひとつの Google Document を表します。
  42. </para>
  43. </sect2>
  44. <sect2 id="zend.gdata.docs.creating">
  45. <title>ドキュメントのアップロード</title>
  46. <para>
  47. 新しい Google Document を作成するには、
  48. ワープロ文書やスプレッドシート、あるいはプレゼンテーションをアップロードします。
  49. この例はインタラクティブなサンプル Docs.php
  50. で、これはライブラリに同梱されています。
  51. これは、ファイルをアップロードした後で、
  52. サーバからその結果の情報を取得して表示するものです。
  53. </para>
  54. <programlisting role="php"><![CDATA[
  55. /**
  56. * Upload the specified document
  57. *
  58. * @param Zend_Gdata_Docs $docs The service object to use for communicating
  59. * with the Google Documents server.
  60. * @param boolean $html True if output should be formatted for display in a
  61. * web browser.
  62. * @param string $originalFileName The name of the file to be uploaded. The
  63. * MIME type of the file is determined from the extension on this file
  64. * name. For example, test.csv is uploaded as a comma seperated volume
  65. * and converted into a spreadsheet.
  66. * @param string $temporaryFileLocation (optional) The file in which the
  67. * data for the document is stored. This is used when the file has been
  68. * uploaded from the client's machine to the server and is stored in
  69. * a temporary file which does not have an extension. If this parameter
  70. * is null, the file is read from the originalFileName.
  71. */
  72. function uploadDocument($docs, $html, $originalFileName,
  73. $temporaryFileLocation) {
  74. $fileToUpload = $originalFileName;
  75. if ($temporaryFileLocation) {
  76. $fileToUpload = $temporaryFileLocation;
  77. }
  78. // Upload the file and convert it into a Google Document. The original
  79. // file name is used as the title of the document and the MIME type
  80. // is determined based on the extension on the original file name.
  81. $newDocumentEntry = $docs->uploadFile($fileToUpload, $originalFileName,
  82. null, Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI);
  83. echo "New Document Title: ";
  84. if ($html) {
  85. // Find the URL of the HTML view of this document.
  86. $alternateLink = '';
  87. foreach ($newDocumentEntry->link as $link) {
  88. if ($link->getRel() === 'alternate') {
  89. $alternateLink = $link->getHref();
  90. }
  91. }
  92. // Make the title link to the document on docs.google.com.
  93. echo "<a href=\"$alternateLink\">\n";
  94. }
  95. echo $newDocumentEntry->title."\n";
  96. if ($html) {echo "</a>\n";}
  97. }
  98. ]]>
  99. </programlisting>
  100. </sect2>
  101. <sect2 id="zend.gdata.docs.queries">
  102. <title>ドキュメントのフィードの検索</title>
  103. <para>
  104. ドキュメントの一覧を検索するには、<ulink
  105. url="http://code.google.com/apis/gdata/reference.html#Queries">
  106. 標準的な Google Data API クエリパラメータ</ulink> を使用します。
  107. カテゴリを使用して、ドキュメントの種類 (ワープロ文書、
  108. スプレッドシート) を絞り込みます。
  109. フルテキストのクエリ文字列を使用して、ドキュメントの全文検索を行います。
  110. ドキュメントの一覧に固有のパラメータについての詳細な情報は、 <ulink
  111. url="http://code.google.com/apis/documents/reference.html#Parameters">
  112. Documents List Data API リファレンスガイド</ulink>
  113. を参照ください。
  114. </para>
  115. <sect3 id="zend.gdata.docs.listwpdocuments">
  116. <title>ワープロ文書の一覧の取得</title>
  117. <para>
  118. 指定した型のすべてのドキュメントを含むフィードを取得することもできます。
  119. たとえば、ワープロ文書の一覧を取得するには、
  120. 次のようなカテゴリクエリを使用します。
  121. </para>
  122. <programlisting role="php"><![CDATA[
  123. $feed = $docs->getDocumentListFeed(
  124. 'http://docs.google.com/feeds/documents/private/full/-/document');]]>
  125. </programlisting>
  126. </sect3>
  127. <sect3 id="zend.gdata.docs.listspreadsheets">
  128. <title>スプレッドシートの一覧の取得</title>
  129. <para>
  130. Google Spreadsheets の一覧を取得するには、
  131. 次のようなカテゴリクエリを使用します。
  132. </para>
  133. <programlisting role="php"><![CDATA[
  134. $feed = $docs->getDocumentListFeed(
  135. 'http://docs.google.com/feeds/documents/private/full/-/spreadsheet');]]>
  136. </programlisting>
  137. </sect3>
  138. <sect3 id="zend.gdata.docs.textquery">
  139. <title>テキストクエリの実行</title>
  140. <para>
  141. ドキュメントの中身を検索するには、リクエスト内で
  142. <classname>Zend_Gdata_Docs_Query</classname> を使用します。
  143. クエリオブジェクトを使用してクエリ URI を組み立て、
  144. 検索する単語をパラメータとして渡します。
  145. これは、ある文字列を含むドキュメントを一覧から探すクエリの例です。
  146. </para>
  147. <programlisting role="php"><![CDATA[
  148. $docsQuery = new Zend_Gdata_Docs_Query();
  149. $docsQuery->setQuery($query);
  150. $feed = $client->getDocumentListFeed($docsQuery);]]>
  151. </programlisting>
  152. </sect3>
  153. </sect2>
  154. </sect1>