dsubq24666 2012-02-06 09:15
浏览 57
已采纳

Zend_GData Spreadsheet - grid-id的查询参数值无效

I am trying to update a google spreadsheet through Zend_GData library. I am sure the user ID and password is correct. I think the issue is with spreadsheet key or worksheet ID. Even I don't know exactly how to get this worksheetID. Kindly help me on this. This is the exact URL to m worksheet.

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

Here is my code.

$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() ;

}

And this is the error message I see on my browser screen.

Expected response code 200, got 400 Invalid query parameter value for grid-id.

  • 写回答

2条回答 默认 最新

  • douyun6399 2012-02-06 10:40
    关注

    I fixed the issue. I could find the SpreadsheetKey and WorkSheetID by using bellow code.

    $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/>";
    }
    

    Once I got those values also my script didn't work. Then I found that when we define the array the 'Key's should mentioned in lower case with no spaces.

    $spreadsheetService->insertRow(array('name'=>'Prasad','value'=>'10000'),$spreadsheetKey,$worksheetId);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 运动想象脑电信号数据集.vhdr
  • ¥15 三因素重复测量数据R语句编写,不存在交互作用
  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目