【发布时间】:2017-08-16 19:01:48
【问题描述】:
我尝试使用 Google Sheets API 从电子表格 (ID) 中获取所有工作表, 我还没有找到这样做的 REST 方法。
我的代码是
$range[]= 'sheet1!A:C';
$response = $service->spreadsheets_values->get($spreadsheetId, $range);
$values = $response->getValues();
$range 的数组或字符串仅在一个值时有效。 具有 mlti 值的数组在 REST 中给出了错误的 url:
$range[]= 'sheet1!A:C';
$range[]= 'SHEET2!A:C';
$response = $service->spreadsheets_values->get($spreadsheetId, $range);
返回以下错误:
致命错误:未捕获的异常“Google_Service_Exception”与 message '调用 GET 时出错 https://sheets.googleapis.com/v4/spreadsheets/[spreadsheetID]/values/Config%21A%3AC,Carte%21A%3AC?key=[my api key]: (400) 无法解析范围:sheet1!A:C,SHEET2!A:C' in C:\Program Files\EasyPHP-12.1\www...\src\Google\Http\REST.php:110 堆栈跟踪:#0 C:\Program 文件\EasyPHP-12.1\www...\src\Google\Http\REST.php(62): Google_Http_REST::decodeHttpResponse(对象(Google_Http_Request), 对象(Google_Client))#1 [内部函数]: Google_Http_REST::doExecute(Object(Google_Client), 对象(Google_Http_Request))#2 C:\Program 文件\EasyPHP-12.1\www...\src\Google\Task\Runner.php(174): call_user_func_array(Array, Array) #3 C:\Program 文件\EasyPHP-12.1\www....\src\Google\Http\REST.php(46): Google_Task_Runner->run() #4 C:\Program 文件\EasyPHP-12.1\www...\src\Google\Client.php(593): Google_Http_REST::execute(Object(C:\Program 中的 Google_Client Files\EasyPHP-12.1\www...\src\Google\Http\REST.php 在第 110 行
谢谢
【问题讨论】:
标签: php google-api google-spreadsheet-api google-api-php-client