Zend_Gdata_Docs.xml 7.8 KB

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