使用Google电子表格更新Fusion表 [英] Using Google Spreadsheet to Update Fusion Table

查看:164
本文介绍了使用Google电子表格更新Fusion表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到的问题是我在更新融合表的电子表格中运行的代码。我运行以下代码(隐私时省略了融合表ID)。

I am having an issue with code I am running in a spreadsheet that updates a fusion table. I run the following code (with the fusion table ID omitted for privacy).

 function updateFusion() {

    var tableIDFusion = '##############################'
    var email = UserProperties.getProperty('email'); 
    var password = UserProperties.getProperty('password');     
      if (email === null || password === null) {
        email = Browser.inputBox('Enter email');
        password = Browser.inputBox('Enter password'); 
        UserProperties.setProperty('email',email); 'email'
        UserProperties.setProperty('password', password); 
      }
      var authToken = getGAauthenticationToken(email,password); 
      deleteData(authToken, tableIDFusion); 
      updateData(authToken, tableIDFusion); 
      SpreadsheetApp.getActiveSpreadsheet().toast(Logger.getLog(), "Fusion Tables Update", 10) 
    }

    //Google Authentication API this is taken directly from the google fusion api website
    function getGAauthenticationToken(email, password) {
      password = encodeURIComponent(password);
      var response = UrlFetchApp.fetch("https://www.google.com/accounts/ClientLogin", {
          method: "post",
          payload: "accountType=GOOGLE&Email=" + email + "&Passwd=" + password + "&service=fusiontables&Source=testing"});
      var responseStr = response.getContentText();
      responseStr = responseStr.slice(responseStr.search("Auth=") + 5, responseStr.length);
      responseStr = responseStr.replace(/\n/g, "");
      return responseStr;
    }

我继续收到错误:
https://www.google.com/accounts/ClientLogin 返回代码403.服务器响应:错误= BadAuthentication (第97行)

I continue to get the error: Request failed for https://www.google.com/accounts/ClientLogin returned code 403. Server response: Error=BadAuthentication (line 97)

我理解编码但不太了解服务器和程序彼此交互的方式,我的方程组网站的代码已经传递给我了我有点不知所措。

I understand coding but not much about servers and the way programs interact with each other and the code for my Formula Team's website has been passed to me and this is all a bit over my head and I am not sure what to do.

非常感谢任何帮助!

推荐答案

我一直在使用类似脚本的版本 John McGrath 通过Google Fusion Tables小组将所有内容整合在一起,创建了一个手动同步谷歌电子表格和谷歌融合表。

I've been using this version of a similar script. John McGrath via the Google Fusion Tables group brought it all together to create a manual "sync" between a Google spreadsheet and a Google Fusion Table.

我猜他们是相似的,但也许你错过了一些方面?

I'm guessing they are similar, but perhaps you are missing some aspects?

我已根据自己的需要修改了脚本,并添加了 API密钥新的Fusion Tables API端点作为原始版本使用的SQL API端点正在逐步淘汰。

I've modified the script a bit for my needs and have added use of an API key and the new Fusion Tables API endpoint as the original version used the SQL API endpoint, which is being phased out.

要使用,只需将Fusion Table的加密表ID添加到脚本的顶部......

To use, simply add your Fusion Table's encrypted table ID to the top of the script...

// Add the encrypted table ID of the fusion table here
var tableIDFusion = '17xnxY......';

并添加 api key ...

// key needed for fusion tables api
var fusionTablesAPIKey = '17xnxY......';

这篇关于使用Google电子表格更新Fusion表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆