简体   繁体   English

无法使Firebase Google App脚本快速入门教程正常工作

[英]Can't Get Firebase Google App Script Quickstart Tutorial to Work

I can't seem to get the Firebase QuickStart to work for me. 我似乎无法让Firebase快速入门对我有用 I'm pretty sure that I followed all of the instructions correctly. 我很确定我正确地遵循了所有说明。 But I'm not getting access to write to the database. 但是我没有访问权限来写入数据库。 And according to the instructions the database is currently open to the public with the suggest rules change displayed below. 根据说明,该数据库当前对公众开放,并在下面显示建议规则更改。 Has anybody ever gone through this tutorial before? 以前有没有人看过本教程? I'd like a hint as to what to do next. 我想暗示下一步该怎么做。

Here's the code. 这是代码。

  function writeDataToFirebase() {
  var ss = SpreadsheetApp.openById("1rV2_S2q5rcakOuHs2E1iLeKR2floRIozSytAt2iRXo8");
  //var ss = SpreadsheetApp.getActive();//I tried running it with data in this spreadsheet copied from the recommended source
  var sheet = ss.getSheets()[0];
  //var sheet = ss.getActiveSheet();
  var data = sheet.getDataRange().getValues();
  var dataToImport = {};
  for(var i = 1; i < data.length; i++) {
    var firstName = data[i][0];
    var lastName = data[i][1];
    dataToImport[firstName + '-' + lastName] = {
      firstName:firstName,
      lastName:lastName,
      emailAddress:data[i][2],
      country:data[i][4],
      department:data[i][5],
      weight:data[i][6],
      birthDate:data[i][7]
    };
  }
  var firebaseUrl = "https://script-examples.firebaseio.com/";
  var base = FirebaseApp.getDatabaseByUrl(firebaseUrl);
  base.setData("", dataToImport);
}

The Data: 数据:

在此处输入图片说明

This is my library dialog: 这是我的库对话框:

在此处输入图片说明

This is the error I keep on getting: 这是我不断得到的错误:

在此处输入图片说明

This name of my script in the FireBase Site: 我在FireBase站点中的脚本的名称:

在此处输入图片说明

This is the access rules change: 这是访问规则的更改:

在此处输入图片说明

So I guess I missed an important point. 所以我想我错过了重要的一点。 The url of firebase database has your projectId in it. firebase数据库的URL中包含您的projectId。 So the url would be something like https://' + projectId + '.firebaseio.com' . 因此,网址应类似于https://' + projectId + '.firebaseio.com' Sorry, to bother everyone with such a simple question. 抱歉,这么一个简单的问题困扰着所有人。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM