从定义ID派生Google表单视图ID

2024-04-24 21:38:45 发布

您现在位置:Python中文网/ 问答频道 /正文

当我定义表单时,它有一个url:

https://docs.google.com/a/domain.com/forms/d/1d2Y9R9JJwymtjEbZI6xTMLtS9wB7GDMaopTQeNNNaD0/edit

我完成了添加问题,我希望表格有和使用“发送”按钮分发我的表格,我没有点击“包括在电子邮件中的形式”复选框。我通过电子邮件向其发送表单的人现在收到并通过电子邮件邀请他们填写表单,当他们填写表单时,他们会出现在具有以下url的页面上:

https://docs.google.com/a/domain.com/forms/d/e/1FAIpQLScINR5rudwEKNVwlvz45ersqk_SO0kNcyN_EM1tJe3mXeFksw/viewform

在我的AppEngine/Python 2.7代码中,我只能访问这个id-“1d2Y9R9JJwymtjEbZI6xTMLtS9wB7GDMaopTQeNNNaD0”-我的问题是如何从这个原始定义id到视图id-“1FAIpQLScINR5rudwEKNVwlvz45ersqk\u SO0kNcyN\u EM1tJe3mXeFksw”

我曾尝试使用googledrivev2和v3restapi检索“definition”文件,但响应没有引用(我可以看到)这个“view”id。 我也尝试过使用googleappsscript FormApp API来检索“definition”表单,但是它也不包含对“view”id的引用(我可以看到)。 在我尝试过的所有情况下,如果我使用'view'ID作为源,API将返回404错误,表明这个'view'ID不是Google驱动器文件的ID

有什么想法吗


Tags: httpscomviewidurl表单docs定义
1条回答
网友
1楼 · 发布于 2024-04-24 21:38:45

使用googleapps脚本发布Web应用程序(或使用执行API)以退出“getPublishedUrl”函数

function doGet(theRequest){
  var theDefinitionId = theRequest.parameters.formId;
  var thePublishedUrl = myAPI_(theDefinitionId);
  var output = ContentService.createTextOutput(thePublishedUrl);
  output = output.setMimeType(ContentService.MimeType.JSON);
  return output;
}

function myAPI_(theDefinitionId){
  var thePublishedUrl = null;
  try{
    var existingForm = FormApp.openById(theDefinitionId);
    thePublishedUrl = existingForm.getPublishedUrl();
  } catch (err){
    Logger.log(err);
  }
  var theReturn = {publishedUrl: thePublishedUrl};
  var theJSONReturn = JSON.stringify(theReturn);
  return theJSONReturn;
}

相关问题 更多 >