I'm trying to use a Google spreadsheet to record data that is entered along the way in my Twine story. I can use the Google Forms paradigm to add new entries to a spreadsheet, but I'd like to be able to load that spreadsheet and pre-populate previous values into the game on a per-user basis, and I'd like to do updates to existing rows in the spreadsheet. However, when I try to use direct access to the spreadsheet (rather than via an associated form), I always get this error:
"No 'Access-Control-Allow-Origin' header is present....."I've shared the spreadsheet globally; tried various permutations of the URL, but nothing seems to work and I can't find much about it on the web, at least that I comprehend.
Here's the kind of JS I'm trying out in a Script passage:
window.queryGoogle = function() {
var json_uri = "
https://docs.google.com/spreadsheets/d/1WhSTBdJnL91T9GnXv3f8p8Hgv_-sYq5lpw5mn0L_Re0/gviz/tq?&tq=&gid=0&usp=sharing";
$.ajax({
type: "GET",
url: json_uri,
xhrFields: { withCredentials: true },
datatype: "jsonp",
success: function(data){
alert(JSON.stringify(data));
}
});
};
Has anyone done this kind of thing recently with the Google spreadsheets (or other doc types)?
Comments
https://spreadsheets.google.com/feeds/list/1WhSTBdJnL91T9GnXv3f8p8Hgv_-sYq5lpw5mn0L_Re0/od6/public/values?alt=json-in-script
Both of the boldfaced portions of the URL can vary depending on the spreadsheet.
You will need to determine why google is not returning an Access-Control-Allow-Origin in there response to you, if that is actually the case. I'm not at a machine currently where I can do that for you.