Hi,
recently I write a documentation about Flickr service for a course
"Programming with Web Services
and JavaScript", and...
If you don't need a JSON callback by default "jsonFlickrApi", you need
write the params in the url:
flickr_url....&format=json&nojsoncallback=1
Also, if you want another name for the JSON callback function you need
the param "jsoncallback"
flickr_url....&format=json&jsoncallback=myFunction
and I have a function myFunction(data){}
If you don't use callback functions and use "normal" AJAX calls, you
have an error with cross domain
(you need some code for proxy the AJAX calls to Flickr).
Then, you can use the technique of dinamic JavaScript loads:
/* This code is part of the example for "Programming with Web Services
and JavaScript" course. University of Murcia. Spain"
var flickr_manager = {
callService: function (params, callback){
fullparams = flickr.extendParams(params,
{
format : "json",
jsoncallback : callback
}
);
var script_call = document.createElement("script");
script_call.type = "text/javascript";
script_call.src = flickr.generateUrl(fullparams);
$("head")[0].appendChild(script_call);
},
getToken: function(data){
alert(data); //show "object" type variable
}
}
//We call to Flickr API with some callback function
flickr.callService({method: "flickr.auth.getToken", frob: flickr.frob},
"flickr.getToken");
philguillard escribió:
Hi all,
I use $.getJSON with flickr REST API, unfortunately flickr is answering:
jsonFlickrApi({"photos":{"page":1, "pages":10, "perpage":100,
"total":"938", "photo":[{"id":"
I guess i should remove "jsonFlickrApi(" header to get the json
interpreted. So i tried:
$.get(url, function(response){
response = response.split("jsonFlickrApi(")[1];
response= response.substr(0,response.length-1);
//var json = JSON.parse(response);
}
but don't knoe how to parse the remaining data as an object
Somebody can help?
Regards,
Phil
--
Best Regards,
José Francisco Rives Lirola <sevir1ATgmail.com>
SeViR CW · Computer Design
http://www.sevir.org
Murcia - Spain