Google应用脚本通过电子表格脚本更新融合表 [英] Google apps script update fusion table from spreadsheet script
问题描述
我想在Google文档电子表格中创建一个应用程序脚本,该脚本将定期从表单中复制行并将其插入到融合表中。下面我贴了我最好的尝试,但应该指出,我真的希望它发布2列范围,而不是那对值。这只是一个占位符。
这里的链接描述了如何与融合表交谈
http://code.google.com/apis/fusiontables/docs/developers_guide.html#Inserting
但我不明白如何编写脚本来实现这一点。我已经搞砸了一堆,我认为我有这些问题
- 我没有正确地形成发布请求
- 我缺少某些认证步骤。
我是一个全新的,我在这里是复制粘贴。一些看起来很有用的资源:
这家伙似乎已经想出了如何编写应用程序脚本来发送请求
http://blog.vivekhaldar.com/post/428652690/google-apps-script- spreadsheets-mashup-hub
这似乎很重要
http://code.google.com/googleapps/appsscript/class_urlfetchapp.html
这些人们似乎在做很类似的事情,但我无法弄清楚如何使它工作
.com / group / fusion-tables-users-group / browse_thread / thread / 99db4db33e405f01function deet(){
var advancedArgs = {
method: ('Blue Shoes',50),
标题:{Authorization:Basic,
payload:?sql =+INSERT INTO 1299801(Text,Number)VALUES你的base64编码用户名:passwd的}};
var response = UrlFetchApp.fetch(
https://www.google.com/fusiontables/api/query\",advancedArgs);
$ / code $ / pre
预先致谢!
以下是一个更新版本通过Google Fusion Tables小组 John McGrath 撰写的脚本,用于在Google之间创建手动同步电子表格和Google Fusion Table。
我已经为我的需要修改了脚本,并添加了 API密钥和 要使用,只需将Fusion Table的加密表ID添加到脚本的顶部即可... 然后添加您的 api key ... I would like to create an apps script in a google docs spreadsheet that will periodically copy rows from the sheet and insert them into a fusion table. Below I've pasted my best attempt, but it should be noted that I really want it to be posting a 2 column range, not that pair of values. That is just a placeholder. This link here describes how to talk to fusion tables
http://code.google.com/apis/fusiontables/docs/developers_guide.html#Inserting But I dont understand how to write the script to achieve this. I've messed around with it a bunch and I think I have these problems -I'm not forming the post request correctly
-I'm missing some sort of authentication step. I am a total newb and what I have here is copy pasted. A few resources that looked helpful: This guy seems to have figured out how to write an app script to send post requests
http://blog.vivekhaldar.com/post/428652690/google-apps-script-spreadsheets-mashup-hub This seems to be important these people seem to be doing somthing very similiar, but I cant figure out how to make it work Thanks in advance! Here's an updated version of a script that John McGrath via the Google Fusion Tables group authored to create a manual "sync" between a Google spreadsheet and a Google Fusion Table. 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. To use, simply add your Fusion Table's encrypted table ID to the top of the script... And add your api key...
这篇关于Google应用脚本通过电子表格脚本更新融合表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
// Add这里融合表的加密表ID
var tableIDFusion ='17xnxY ......';
//融合表所需的键api
var fusionTablesAPIKey ='17xnxY ......';
http://code.google.com/googleapps/appsscript/class_urlfetchapp.html
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);
}
// Add the encrypted table ID of the fusion table here
var tableIDFusion = '17xnxY......';
// key needed for fusion tables api
var fusionTablesAPIKey = '17xnxY......';