DIA access from Google Apps

Uncle!

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.

http://developer.idigi.com/ws/DiaChannelDataFull?_username=XXXX&_password=XXXXXX

So I substitute string above into simple function below and I get access error.

function myFunction() {
// The code below shows the HTML code of the Google home page.
var response = UrlFetchApp.fetch(“http://developer.idigi.com/ws/DiaChannelDataFull?_username=xxxxx&_password=xxxxx”);
Browser.msgBox(response.getContentText());
}

same for function importXML
“=importXML(“http://developer.idigi.com/ws/DiaChannelDataFull?_username=XXX&_password=XXXXXX”, “/result”)”

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.

Hello,

I did some searching on how to do basic authentication in app engine and came across this link: http://productforums.google.com/forum/#!msg/apps-script/-yiKPQZNJAA/LScknnqBkAUJ, which looks helpful other than the example code putting an extra space in the authorization header.

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;

var response = UrlFetchApp.fetch(http://developer.idigi.com/ws/DiaChannelDataFull",
{
headers: {“Authorization”: digestfull}
});

cpopp - I owe you a virtual beer!

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++;
}
}