Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 谷歌应用程序脚本:";失踪'';“在声明之前”;_Javascript_Google Apps Script_Google Drive Api_Google Spreadsheet Api - Fatal编程技术网

Javascript 谷歌应用程序脚本:";失踪'';“在声明之前”;

Javascript 谷歌应用程序脚本:";失踪'';“在声明之前”;,javascript,google-apps-script,google-drive-api,google-spreadsheet-api,Javascript,Google Apps Script,Google Drive Api,Google Spreadsheet Api,今天是我使用谷歌应用程序脚本的第一天。我正在尝试制作一个脚本,从WundergroundAPI获取天气信息,并将其粘贴到电子表格中 由于某种原因,我得到了错误消息“Missing';”before语句(第34行)。 我已搜索解决方案,但找不到代码中出现此错误的原因 //Everyday this script gets weather data from Weather Underground and records it in this spreadsheet. cDay = 0, cTem

今天是我使用谷歌应用程序脚本的第一天。我正在尝试制作一个脚本,从WundergroundAPI获取天气信息,并将其粘贴到电子表格中

由于某种原因,我得到了错误消息“Missing';”before语句(第34行)。 我已搜索解决方案,但找不到代码中出现此错误的原因

//Everyday this script gets weather data from Weather Underground and records it in this spreadsheet.

cDay = 0, cTemp = 1, cHumidity = 2, cPressure=3, cSparkline=4, cConditions=5;
nCols=7;

function getTemp() {

  var url = 'http://api.wunderground.com/api/' + appKey + '/conditions/q/CO/Aspen.json';
  var sheet = SpreadsheetApp.getActiveSheet();
  var rows = sheet.getDataRange();
  var numRows = rows.getNumRows();
  var response = UrlFetchApp.fetch(url);

  var contentText = response.getContentText();
  var conditions = Utilities.jsonParse(contentText);
  var todaysConditions = conditions;

  var temp = todaysConditions.current_observation.temp_c;
  var humidity = todaysConditions.current_observation.relative_humidity;
  var pressure = todaysConditions.current_observation.pressure_in;
  var conditions = todaysConditions.response.features.conditions;  

  sheet.insertRowAfter(1);
  var range = sheet.getRange(2,1,1, nCols);
  var row = range.getValues()[0];

  var d = new Date;
  var month = d.getMonth() + 1;
  var day = d.getDate();
  var year = d.getFullYear();
  var hour = d.getHours() + 1;
  var minutes = d.getMinutes();

  row[cDay] = month + '/' + day + '/' + year + '' + hour + ':' minutes; //here is the error
  row[cTemp] = temp;
  row[cHumidity] = humidity;
  row[cPressure] = pressure;
  row[cConditions] = conditions;
  var nRows = numRows >= 10 ? 10 : numRows;
  //row[cSparkline] = "=SPARKLINE(R[0]C[-3]:R[" + (nRows-1) + "]C[-3])";
  range.setValues([row]); 

}

感谢您的帮助

您错过了“+”符号


行[cDay]=月+'/'+日+'/'+年+'+小时+':'+分钟

有时每个人都会遇到这种情况:)