Google应用脚本更新电子表格脚本中的融合表

max*_*max 3 google-docs google-apps google-sheets google-apps-script google-fusion-tables

我想在google docs电子表格中创建一个应用程序脚本,它会定期从工作表中复制行并将它们插入到融合表中.下面我粘贴了我最好的尝试,但应该注意的是,我真的希望它发布2列范围,而不是那对值.那只是一个占位符.

此链接描述了如何与融合表对话 http://code.google.com/apis/fusiontables/docs/developers_guide.html#Inserting

但我不明白如何编写脚本来实现这一目标.我已经乱搞了一堆,我想我有这些问题

- 我没有正确地形成发布请求 - 我错过了某种身份验证步骤.

我是一个全新的,我在这里复制粘贴.一些看起来有用的资源:

这家伙似乎已经想通了如何编写一个应用程序脚本发送POST请求 http://blog.vivekhaldar.com/post/428652690/google-apps-script-spreadsheets-mashup-hub

这似乎很重要

http://code.google.com/googleapps/appsscript/class_urlfetchapp.html
Run Code Online (Sandbox Code Playgroud)

这些人似乎在做类似的事情,但我无法弄清楚如何让它发挥作用

http://groups.google.com/group/fusion-tables-users-group/browse_thread/thread/99db4db33e405f01


function deet() {
  var advancedArgs = {
      method: "post", 
      payload: "?sql=" + "INSERT INTO 1299801(Text, Number) VALUES ('Blue Shoes', 50)", 
      headers: {"Authorization": "Basic <base64 encoding of your username:passwd"}};
  var response = UrlFetchApp.fetch(
      "https://www.google.com/fusiontables/api/query",advancedArgs);

}
Run Code Online (Sandbox Code Playgroud)

提前致谢!

小智 5

以下是John McGrath通过Google Fusion Tables小组创作的脚本的更新版本,用于在Google电子表格和Google Fusion Table之间创建手动"同步".

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

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

// Add the encrypted table ID of the fusion table here
var tableIDFusion = '17xnxY......';
Run Code Online (Sandbox Code Playgroud)

并添加你的api密钥 ......

// key needed for fusion tables api
var fusionTablesAPIKey = '17xnxY......';
Run Code Online (Sandbox Code Playgroud)