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
http://code.google.com/googleapps/appsscript/class_urlfetchapp.html
these people seem to be doing somthing very similiar, but I cant figure out how to make it work
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);
}
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...
// Add the encrypted table ID of the fusion table here
var tableIDFusion = '17xnxY......';
And add your api key...
// key needed for fusion tables api
var fusionTablesAPIKey = '17xnxY......';