gpt4 book ai didi

php - Zend_GData 电子表格 - grid-id 的无效查询参数值

转载 作者:可可西里 更新时间:2023-11-01 00:50:15 27 4
gpt4 key购买 nike

我正在尝试通过 Zend_GData 库更新 google 电子表格。我确信用户 ID 和密码是正确的。我认为问题出在电子表格键或工作表 ID 上。甚至我也不知道如何得到这个worksheetID。请帮我解决这个问题。这是 m 工作表的确切 URL。

https://docs.google.com/spreadsheet/ccc?key=0AmW1-CVeX7oOdGRkYURWNXVMRi1DTW9NTGNhZ09OTGc&hl=en_US#gid=0

这是我的代码。

$user = 'xxxxxxxxxxxxxxxxxxxxxx';
$pass = 'xxxxxxxxxxxxxxxxxx';
$service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$spreadsheetService = new Zend_Gdata_Spreadsheets($client);
$spreadsheetKey = "0AmW1-CVeX7oOdGRkYURWNXVMRi1DTW9NTGNhZ09OTGc";
$worksheetId = "Sheet1";
try
{
$spreadsheetService->insertRow(array('Prasad','10000'),$spreadsheetKey,$worksheetId);

}
catch(Exception $error)
{

echo $error->getMessage() ;

}

这是我在浏览器屏幕上看到的错误消息。

预期响应代码 200,得到 400 Invalid query parameter value for grid-id。

最佳答案

我解决了这个问题。我可以使用下面的代码找到 SpreadsheetKey 和 WorkSheetID。

$user = 'xxxxxxxxxxxxxxx';
$pass = 'xxxxxxxxxxxxx';
$service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME;
$client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
$spreadsheetService = new Zend_Gdata_Spreadsheets($client);
$feed = $spreadsheetService->getSpreadsheetFeed();
$sheetName = "Test1";
foreach($feed->entries as $entry)
{
if($entry->title->text == $sheetName)
{
$spreadsheetURL = $entry->id;
break;
}
}

$spreadsheetKey = basename($spreadsheetURL);

$query = new Zend_Gdata_Spreadsheets_DocumentQuery();
$query->setSpreadsheetKey($spreadsheetKey);
$feed = $spreadsheetService->getWorksheetFeed($query);

echo "Spreadskeet Key : $spreadsheetKey <br/>";

foreach($feed->entries as $entry)
{
echo "ID of sheet {$entry->title->text} is " . basename($entry->id) . " <br/>";
}

获得这些值后,我的脚本也无法正常工作。然后我发现当我们定义数组时,'Key' 应该以小写形式提及并且没有空格。

$spreadsheetService->insertRow(array('name'=>'Prasad','value'=>'10000'),$spreadsheetKey,$worksheetId);

关于php - Zend_GData 电子表格 - grid-id 的无效查询参数值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9157845/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com