I am trying to access the DIA from Google Apps using javascript or function importXML. I have tried all the examples in idigi docs with no joy. I keep getting the error “full authentification required - 401”. The following string works perfect in firefox, but not in google apps.
Very frustrated as I can’t even get to first base. Scoured to web for examples - no joy.
All I want to do is pull latest values from DIA and shove them into a google spreadsheet. Yes - I can link browser query to excel on my laptop using .xls option, but want to access the data and graph from anywhere and have it automatically update the time series using google app spreadsheet.
I haven’t coded in app engine before, but based on that it looks like the following or something like it might help. I think the problem is app engine won’t pull the credentials out of the URL.
var unamepass =“myusername:mypassword”;
var digest = Utilities.base64Encode(unamepass);
var digestfull = "Basic "+digest;
I finally am able to get a toehold in figuring this out.
Works like a champ!
working code:
function init(){
var unamepass =“username:password”;
var digest = Utilities.base64Encode(unamepass);
var digestfull = ("Basic "+digest);
var response = UrlFetchApp.fetch (“http://developer.idigi.com/ws/DiaChannelDataFull/.json”, {method: “get”, headers: {“Authorization”: digestfull}});
/* Browser.msgBox(response.getContentText()); */
var fields = {‘in_reply_to_screen_name’:true,‘created_at’:true,‘text’:true};
var o = Utilities.jsonParse(response.getContentText());
var doc = SpreadsheetApp.getActiveSpreadsheet();
var cell = doc.getRange(‘a1’);
var index = 0;
for (var i in o) {
var row = o[i];
var col = 0;
for (var j in row) {
cell.offset(index, col).setValue(row[j]);
col++;
}
index++;
}
}