【发布时间】:2017-07-05 08:45:08
【问题描述】:
我已尝试使用以下代码在电子表格中创建新工作表,但它不起作用。
$service = new Google_Service_Sheets($client);
//pr($service);
$spreadsheetId = ‘You spredsheet id’;
$json_request_string = ‘{“requests”:[{“addSheet”: {“properties”: {“title”: “Project tasks”}}}]}’;
//$requests = json_decode($json_request_string);
// TODO: Assign values to desired properties of `requestBody`:
$requestBody = new Google_Service_Sheets_BatchUpdateSpreadsheetRequest();
$requestBody->setRequests($json_request_string);
$response = $service->spreadsheets->batchUpdate($spreadsheetId, $requestBody);
我收到此错误:
请求具有无效的身份验证凭据错误
【问题讨论】:
-
它会给你任何错误吗?
-
是的,我收到“请求具有无效的身份验证凭据错误。但我认为这是无效请求错误。
-
我会从你的身份验证开始。查看 $client 并确认所有设置都正确。
标签: php google-sheets google-api google-sheets-api