使用 Zend Gdata 从 Google Docs 删除文档
我在使用 Google Docs 和 Zend Framework 1.11.4 时遇到问题。
我想做的是将文档上传到 Google Docs,检索 HTML 内容并删除该文档。我正在处理 .doc、.pdf 和 .rtf 文件。
到目前为止,我的代码:
$client = Zend_Gdata_ClientLogin::getHttpClient(
'[email protected]',
'MyPassword',
Zend_Gdata_Docs::AUTH_SERVICE_NAME
);
$gdClient = new Zend_Gdata_Docs($client);
$newDocumentEntry = $gdClient->uploadFile(
$file,
null,
null,
Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI
);
$cv = file_get_contents($newDocumentEntry->getContent()->getSrc());
$newDocumentEntry->delete();
一切正常,直到调用 ->delete() 方法,它返回异常 预期响应代码 200,得到 409
我已经在谷歌上搜索了几天了,但是找不到答案,根据Google的文档这是删除文档的正确方法。
如果有人知道我做错了什么,那么非常欢迎任何帮助。
预先非常感谢, 加里
I am having trouble working with Google Docs and Zend Framework 1.11.4.
What I am attempting to do is upload a document to Google Docs, retrieve the HTML content and delete the document. I am working with .doc, .pdf, and .rtf files.
My code so far:
$client = Zend_Gdata_ClientLogin::getHttpClient(
'[email protected]',
'MyPassword',
Zend_Gdata_Docs::AUTH_SERVICE_NAME
);
$gdClient = new Zend_Gdata_Docs($client);
$newDocumentEntry = $gdClient->uploadFile(
$file,
null,
null,
Zend_Gdata_Docs::DOCUMENTS_LIST_FEED_URI
);
$cv = file_get_contents($newDocumentEntry->getContent()->getSrc());
$newDocumentEntry->delete();
Everything works fine until the ->delete() method is called, it returns an exception Expected response code 200, got 409
I have been Googling this for a couple of days now but can find no answer, according to Googles documentation this is the correct way to delete a document.
If anyone has any idea as to what I am doing wrong then any help would be very welcome.
Many thanks in advance,
Garry
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 Zend_Gdata_Calendar 库时,我遇到了同样的 409 响应问题。 Zend 框架错误跟踪器上有一个未解决的错误。请参阅 http://zendframework.com/issues/browse/ZF-10194
似乎归结为缺少由 Gdata_App 类或链中的子类之一设置的“If-Match”标头。
为了修复 Calendar API 的问题,我重写了 Zend_Gdata_Calendar 类并实例化了我的类而不是该类:
然后使用它:
我想您可以做同样的事情,但重写 Zend_Gdata_Docs 类。
I was having the same 409 response issue when using the Zend_Gdata_Calendar library. There is an open bug on the Zend framework bugtracker. See http://zendframework.com/issues/browse/ZF-10194
It seems to boil down to the lack of a "If-Match" header being set by the Gdata_App class or one of the child classes in the chain.
To fix it for the Calendar API I've overridden the Zend_Gdata_Calendar class and instantiated my class instead of that one:
Then use it:
I imagine you could do the same thing but overriding the Zend_Gdata_Docs class instead.