使用应用程序脚本发布Google工作表

时间:2017-03-31 02:03:13

标签: google-apps-script google-sheets

下面的脚本工作到大约一周前。我检查了开发人员仪表板,但我不知道发生了什么变化。我想知道是否有人有通过应用程序脚本发布谷歌电子表格的替代方法,或者我如何让脚本再次运行。

function publishSheet(sheetId) {
  //DriveApp.getRootFolder(); Needed for Scope
  if (!sheetId) {sheetId = "1gshaH5buTPFmm8elky0zWXqPYSO6BahK_OT7uFLrrgw"};

  var payload = {
    "published":true,
    "requireSignin":false,
    "entireDocument":true
  }


  var url = "https://docs.google.com/a/cc..org/spreadsheets/d/"+sheetId+"/publishingsettings?id=" + sheetId
//  var url = "https://docs.google.com/spreadsheets/u/2/d/"+sheetId+"/publishingsettings?id=" + sheetId
  var options = {
    method:"POST",
    contentType:"application/x-www-form-urlencoded;charset=UTF-8",
    headers:{
      Authorization:"Bearer " + ScriptApp.getOAuthToken()
    },
    payload:payload,
    muteHttpExceptions:true
  }

  var resp = UrlFetchApp.fetch(url,options);
  //Logger.log(resp) //no real response just some random characters. 
}

0 个答案:

没有答案