使用 zend gdata 插件上传文档

发布于 2024-12-21 02:29:40 字数 517 浏览 3 评论 0原文

我正在尝试使用 Zend_Gdata 插件将文档上传到 Google 文档。它上传得很好。

但该文档默认变为私有。我怎样才能将其设置为公开。如何获取我的文档的文档 ID 和 URL 链接,以便其他人只能访问它以进行查看?

$service = Zend_Gdata_Docs::AUTH_SERVICE_NAME;
$client  = Zend_Gdata_ClientLogin::getHttpClient($email, $passwd, $service);
$docs    = new Zend_Gdata_Docs($client);
$feed    = $docs->getDocumentListFeed();

$newDocumentEntry = $docs->uploadFile(
    $filename, $name, null, Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI
);

我很感激任何帮助。

谢谢

I am trying to upload a document into Google docs using the Zend_Gdata plugin. It uploads fine.

But the document by default becomes private. How can I set it to public. And how can I get the doc id and URL link to my doc so that others can access it to view only?

$service = Zend_Gdata_Docs::AUTH_SERVICE_NAME;
$client  = Zend_Gdata_ClientLogin::getHttpClient($email, $passwd, $service);
$docs    = new Zend_Gdata_Docs($client);
$feed    = $docs->getDocumentListFeed();

$newDocumentEntry = $docs->uploadFile(
    $filename, $name, null, Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI
);

I appreciate any help.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

黑凤梨 2024-12-28 02:29:40

您必须提供一个不同的 URI 作为 uploadFile() 函数的第四个参数,您使用的 URI 会将文档发送到私有。 (观察下面)

Zend_Gdata_Docs 查看源代码。

class Zend_Gdata_Docs extends Zend_Gdata
{
    const DOCUMENTS_LIST_FEED_URI 
        = 'https://docs.google.com/feeds/documents/private/full';
    // ...

如您所见,类 const 链接到私有路径。您必须使用 public,而不是使用 Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI但是,根据 Google 文档列表 Feed API,看来他们接受私有

可见性参数有两个可能的值:私有和公共。

注意:目前,私有是文档列表 API 中唯一可用的可见性。有关详细信息,请参阅下面的可见性值。< /p>


顺便说一句,最终结果应该返回一个 Zend_Gdata_App_Entry 对象到 $newDocumentEntry ,我认为你应该能够调用像 $newDocumentEntry->getEditLink 这样的函数() 等。

如果您想查看该对象中还存储了什么内容:

Zend_Debug::dump($newDocumentEntry);

祝您好运!

You must supply a different URI as the fourth parameter to the uploadFile() function, the one you're using will send docs to private. (Observe below)

Check out the source code from Zend_Gdata_Docs.

class Zend_Gdata_Docs extends Zend_Gdata
{
    const DOCUMENTS_LIST_FEED_URI 
        = 'https://docs.google.com/feeds/documents/private/full';
    // ...

As you can see, the class const is linking to a private path. Instead of using Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI, you would have to use public. However, according to Google's Documents List Feed API, it appears they only accept private.

The visibility parameter has two possible values: private and public.

Note: Currently, private is the only visibility available in the Documents List API. For more information, see Visibility values, below.


By the way, the end result should return a Zend_Gdata_App_Entry object to $newDocumentEntry with which I think you should be able to call functions like $newDocumentEntry->getEditLink() etc.

If you want to see what else is stored in that object that do this:

Zend_Debug::dump($newDocumentEntry);

Good luck!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文