【问题标题】:Google Docs API - Zend gData - How to find the URI of a collectionGoogle Docs API - Zend gData - 如何找到集合的 URI
【发布时间】:2012-05-07 08:45:18
【问题描述】:

我有一个 Zend_Gdata_App_Entry 类型的条目,

此条目是一个集合/文件夹,我尝试获取此文件夹的 URI,

我知道 URI 是一个 URL,但条目的 id 也是一个 URL,有什么区别?

我想这样做:

// Instantiate a FolderQuery object to retrieve the content of the folder.
FolderQuery contentQuery = new FolderQuery(folder.ResourceId);

URI = contentQuery.Uri

但不是在 .NET 中,而是在 PHP 中使用 Zend gdata 框架

谢谢!

【问题讨论】:

    标签: php zend-framework gdata google-docs-api google-drive-api


    【解决方案1】:

    在 GData 中,self URI 和 ID 通常比较相似。所以,如果你有一个或另一个,它真的并不重要。 ResourceID 有点不同,因为它们不是 URL,而是采用folder:1234 的形式。如果您在 folder: 前缀后面有数字,则可以轻松构建它们。如果您仔细查看从资源 ID 构造的文档的 ID。所有这些都存在实际差异,它们大多是 GData 协议所需要的。

    无论如何,一旦您获得了文件夹的 ID 或资源 ID,您就可以使用以下 URL 列出其内容:

    https://docs.google.com/feeds/default/private/full/folder%3A1234/contents
    

    只需确保将 folder%3A1234 替换为文件夹的实际资源 ID。

    然后您可以在方法Zend_Gdata_Docs.getDocumentListFeed(String location) 中使用该URL 作为位置属性。这将为您提供包含文件夹内所有元素的文档提要。

    【讨论】:

      【解决方案2】:

      也许这会对你有所帮助。创建子文件夹,然后将文件上传到新文件夹:

      $service = Zend_Gdata_Docs::AUTH_SERVICE_NAME;
      $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
      $docs = new Zend_Gdata_Docs($client);
      
      $parentFolder = 'folder%3A[folderid]';    
      
      $newFolder = $docs->createFolder($_POST['email'], $parentFolder);
      
      $location = str_replace($parentFolder . '/', '', $newFolder->getSelfLink()->getHref());
      
      // Upload the file to google docs
      $newDocumentEntry = $docs->uploadFile(
          $fileToUploadTemp, 
          $fileToUpload, 
          Zend_Gdata_Docs::lookupMimeType($fileExtension),
          $location
      );
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-04-03
        • 1970-01-01
        • 2012-03-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多