在谷歌应用程序脚本中,我编写以下代码来阅读来自谷歌表单的回复
function formResponse()
{
var form = FormApp.openById('form-id');
var formResponses = form.getResponses();
for (var i = 0; i < formResponses.length; i++)
{
var formResponse = formResponses[i];
var itemResponses = formResponse.getItemResponses();
for (var j = 0; j < itemResponses.length; j++)
{
var itemResponse = itemResponses[j];
Logger.log('Response #%s to the question "%s" was "%s"',
(i + 1).toString(),
itemResponse.getItem().getTitle(),
itemResponse.getResponse());
}
}
return formResponses;
}
谷歌应用程序脚本日志中的成功输入了我期望的内容。
在PHP中我使用以下代码来调用谷歌应用程序脚本。
$accessToken = $client->authenticate($request->input('code'));
$client->setAccessToken($accessToken);
$service = new \Google_Service_Script($client);
$scriptId = 'MIQpTICu_Gobs7BEB-v3lHZZMYprHmXMAQrb';
// Create an execution request object.
$request = new \Google_Service_Script_ExecutionRequest();
$request->setFunction('formResponse');
$responses = $service->scripts->run($scriptId, $request);
$resp = $responses->getResponse();
print_r($resp);
它没有获得任何表单回复值
答案 0 :(得分:0)
我返回formresponses而不是返回数组对象。