0

我想在我的应用程序中(在 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/(如示例)。

如何解决此错误?

4

1 回答 1

2

我发现了我的错误,当您想要更新单元格时,我在 Zend 库 1.11 中发现了一个错误。

所以我的第一个错误是我把这个范围:

http://spreadsheets.google.com/feeds/spreadsheets/

好的范围是:

http://spreadsheets.google.com/feeds/

更新错误单元格是当您在不安全范围内工作时,Zend 在 https 协议中发送 PUT 请求 http,因此 Google 不希望这样做。

对于我的测试(这不是一个好的解决方案,但对于测试来说,没关系^^),我在 put 函数的 Zend/Gdata/App.php 文件中添加了这一行:

$requestData['url'] = str_replace('https', 'http', $requestData['url']);

这是工作:)

于 2010-11-18T22:48:08.923 回答