Hi,

First off, please put the examples into mooshell.net.

Secondly, I don't have the time to go through the code you've posted right now, so I'll just post a link to the script I've written months ago, perhaps you'll find your answer there: http://blog.olicio.us/public/weblog/MooFlickrBadge/

O.

On 9 Sep 2009, at 03:17, Fraction wrote:


Need some help using Request.JSONP with the Flickr API.  I haven't
been able to get a JSONP request to work without including the
"jsoncallback" parameter.  This is not a required parameter in the API
url string and there is even a parameter to  NOT have a JSON call
back  ("nojsoncallback=1"), however this isn't working for me either
even though I follow the [url=http://www.flickr.com/services/api/
response.json.html]documentation[/url].  I don't want to have to
define a call back function as I can't pass any kind of parameters to
it.  I want to handle everything in the onComplete handler of the
Request.  Below are 3 examples of various code setups as well as the
associated firebug console output for each.  Anyone with some Flickr
API experience, or just any possible idea, I would greatly appreciate
some advice.

Ex: 1 - Successful in that it calls the assigned function in the
"jsoncallback" attribute and the proper data is alerted, however the
onComplete handler never fires.

function infoHandler( data ) {
   alert( data.photo.description._content );
}

var setRequest = new Request.JSONP({
   url: 'http://api.flickr.com/services/rest/',
   data: {
       method:         'flickr.photos.getInfo',
       api_key:        //api key goes here,
       photo_id:       '3647421828',
       format:         'json',
       jsoncallback:   'infoHandler'
   },
   onComplete: function( data ) {
       alert( 'requet complete' );
   }
}).send();

Ex: 1 Console Output
["JSONP retrieving script with url:
http://api.flickr.com/services/rest/?callback=Request.JSONP.request_map.request_0&method=flickr.photos.getInfo&api_key=api_key_here&photo_id=3647421828&format=json&jsoncallback=infoHandler "]

Ex 2: - Passing the "nojsoncallback" parameter.  JSON Output looks
fine to me but fails due to a "invalid label".  Not sure what that
means.  Again, onComplete handler never fires.

var setRequest = new Request.JSONP({
   url: 'http://api.flickr.com/services/rest/',
   data: {
       method:     'flickr.photos.getInfo',
       api_key:        //api key goes here,
       photo_id:       '3647421828',
       format:         'json',
       nojsoncallback: '1'
   },
   onComplete: function( data ) {
       alert( 'requet complete' );
   }
}).send();

Ex: 2 Console Output
["JSONP retrieving script with url:
http://api.flickr.com/services/rest/?callback=Request.JSONP.request_map.request_0&method=flickr.photos.getInfo&api_key=api_key_here&photo_id=3647421828&format=json&nojsoncallback=1 "]
invalid label
{"photo":{"id":"3647421828", "secret":"9...:{"nsid":"8317...@n05",
"username":"frac

Ex: 3 - Does not include a "jsoncallback" or "nojsoncallback"
parameter at all.  Fails due to JSONFlickrAPI not being defined.
Again, onComplete handler never fires.

code
var setRequest = new Request.JSONP({
   url: 'http://api.flickr.com/services/rest/',
   data: {
       method:     'flickr.photos.getInfo',
       api_key:        //api key goes here,
       photo_id:       '3647421828',
       format:         'json'
   },
   onComplete: function( data ) {
       alert( 'requet complete' );
   }
}).send();

Ex: 3 Console Output
["JSONP retrieving script with url:
http://api.flickr.com/services/rest/?callback=Request.JSONP.request_map.request_0&method=flickr.photos.getInfo&api_key=api_key_here&photo_id=3647421828&format=json "]
jsonFlickrApi is not defined
rest?
callback = Request.JSONP.request_map.request_0 &method = flickr.photos.getInfo &api_key=api_key_here&photo_id=3647421828&format=json
()

Reply via email to