logo       

[Flickr APIs] xmlhttprequest help: msg#00018

web.flickr.api

Subject: [Flickr APIs] xmlhttprequest help

Hi,

I am a happy flickr user and hobbyist enthusiast developer, a newbie
starting to play with Flickr API. I am using this XML HTTPRequest
tutorial as a starting point:
http://developer.apple.com/internet/webcontent/xmlhttpreq.html

I have made a simple javascript test app that calls
flickr.photosets.getPhotos to generate an html code with all
thumbnails from a set. The code is below:

-----------------
var url =
"http://www.flickr.com/services/rest/?method=flickr.photosets.getPhotos";
var user_id = "49503114626@N01"
var photoset_id = "3913"
var api_key = "72fadaff0fad605613c6caeb8a09f85d"
var params = "&api_key="+api_key+"&photoset_id="+photoset_id
var req;

function loadXMLDoc(url) {
// branch for native XMLHttpRequest object
if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
req.onreadystatechange = processReqChange;

netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
req.open("GET", url, true);
req.send(null);
// branch for IE/Windows ActiveX version
} else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
if (req) {
req.onreadystatechange = processReqChange;
req.open("GET", url, true);
req.send();
}
}
}

function processReqChange() {
// only if req shows "loaded"
if (req.readyState == 4) {
// only if "OK"
if (req.status == 200) {
var xmlResponse = req.responseXML;
if(xmlResponse.documentElement){
var idphotos = []
var photoset =
xmlResponse.documentElement.firstChild //photoset
for(var photo =
photoset.firstChild;photo!=null; photo = photo.nextSibling){
idphotos.push(photo.getAttribute("id"))
}
printPhotos(idphotos)
}else{
alert("error")
}
} else {
alert("There was a problem retrieving the XML data:\n" +
req.statusText);
}
}
}
function printPhotos(ids){
var str = ""
for (var i=0; i<ids.length;i++){
str +="<a
href='http://www.flickr.com/photo.gne?id="+ids[i]+";'><img
src='http://www.flickr.com/photos/"+ids[i]+"_"+user_id+"_s.jpg'
/></a>"
}
document.write(str)
}
loadXMLDoc(url+params)
-----------------

It works fine if I run it locally on IE, but on Firefox I receive the
follow error:

Error: [Exception... "'Permission denied to get property
XMLDocument.documentElement' when calling method:
[nsIOnReadystatechangeHandler::handleEvent]" nsresult: "0x8057001e
(NS_ERROR_XPC_JS_THREW_STRING)" location: "<unknown>" data: no]


Anyone knows what could be wrong, or some other way to make it?

PS: I dont have one API Key yet, I had requested one by email but
meanwhile I am using a borrowed one from the flickr demo pages :(

--
Fabricio C Zuardi
http://idomyownstunts.blogspot.com



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise