PHP:Zend:错误的范围和 Google API 电子表格
我想在我的应用程序中(在 php 中)操作 Google Spreasheet,因此,为此,我想将 google docs api 与 zend gdata 库结合使用。
我在 zend 示例文档中获取此代码,但收到错误 500:
$_SESSION['docsSampleSessionToken'] = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']);
$client = Zend_Gdata_AuthSub::getHttpClient($_SESSION['docsSampleSessionToken']);
$gdClient = new Zend_Gdata_Spreadsheets($client);
$feed = $gdClient->getSpreadsheetFeed();
$currKey = explode('/', $feed->entries[0]->id->text);
$query = new Zend_Gdata_Spreadsheets_DocumentQuery();
$query->setSpreadsheetKey($currKey);
$feed = $gdClient->getWorksheetFeed($query);
当我删除此行时,一切正常:
$feed = $gdClient->getWorksheetFeed($query);
我的错误是“错误的范围”,并且身份验证期间的范围是 http://spreadsheets.google.com/feeds/spreadsheets/(如示例)。
如何解决这个错误?
I want to manipulate Google Spreasheet in my application (in php), so, to do this, I want to use the google docs api with the zend gdata librairy.
I take this code in the zend sample docs but I get an error 500:
$_SESSION['docsSampleSessionToken'] = Zend_Gdata_AuthSub::getAuthSubSessionToken($_GET['token']);
$client = Zend_Gdata_AuthSub::getHttpClient($_SESSION['docsSampleSessionToken']);
$gdClient = new Zend_Gdata_Spreadsheets($client);
$feed = $gdClient->getSpreadsheetFeed();
$currKey = explode('/', $feed->entries[0]->id->text);
$query = new Zend_Gdata_Spreadsheets_DocumentQuery();
$query->setSpreadsheetKey($currKey);
$feed = $gdClient->getWorksheetFeed($query);
When I remove this line, all work fine:
$feed = $gdClient->getWorksheetFeed($query);
My error is "wrong scope" and my scope during the authentification is http://spreadsheets.google.com/feeds/spreadsheets/ (like the sample).
How to resolve this error ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现了我的错误,当你想更新单元格时,我在 Zend librairy 1.11 中发现了一个错误。
所以我的第一个错误是我设置了这个范围:
http://spreadsheets.google.com/feeds/spreadsheets/
好的范围是:
http://spreadsheets.google.com/feeds/
更新错误单元是当您在不安全范围内工作时,Zend 在 https 协议中发送 PUT 请求 http,因此 Google 不希望出现这种情况。
对于我的测试(这不是一个好的解决方案,但对于测试来说,没关系^^),我在文件 Zend/Gdata/App.php 的 put 函数中添加了这一行:
它可以工作:)
I found my error and I found an error in Zend librairy 1.11 when you want to update a cell.
So my first error is I put this scope:
http://spreadsheets.google.com/feeds/spreadsheets/
And the good scope is:
http://spreadsheets.google.com/feeds/
And the update error cell is that Zend send a PUT request http in https protocol when you work in unsecure scope, so Google doesn't want this.
For my test (it's not a good solution but for a test, it's ok ^^), I add this line in the file Zend/Gdata/App.php in the put function:
And it's work :)