Question about the Callback parameter

diligentdiligent Registered Users Posts: 3 Beginner grinner
For the API 1.2.2, what does the Callback parameter do?

Does it exist to support a specific style of communication? (for example AJAX?)

Are there any specifications and/or links to better explain this parameter?

Thanks,

Comments

  • devbobodevbobo Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
    edited August 3, 2009
    G'day Paul,

    The callback parameter was specifically implemented for JSONP. Which allows ajax calls to be made without the headaches of cross domain issues.

    To do so, you would embed a script element on your webpage with the url of a specific SmugMug api call...kinda like this...

    <*script* src="http://api.smugmug.com/services/api/json/1.2.2/?method=smugmug.albums.get&Callback=myCallback"&gt;

    The JSON response is then wrapped within the call to myCallback, like this...

    myCallback({"stat": "ok", "method": "smugmug.albums.get", "Albums": []});

    This assumes that myCallback is defined locally.

    That's pretty much it, googling JSONP should fill in any other blanks.

    Cheers,

    David
    David Parry
    SmugMug API Developer
    My Photos
  • diligentdiligent Registered Users Posts: 3 Beginner grinner
    edited August 10, 2009
    Thanks David,

    That fills in the gap nicely. Is there any way to update the public api documentation with this information?

    I suppose for now maybe I can leave a comment on the doc page...
Sign In or Register to comment.