How to to send and retrieve data from flickr flickr.test.echo method using JQuery Ajax REST?
Solution 1
Use Flickr's JSON format API and jQuery.getJSON
like sktrdie suggested - just remember to append callback=?
to the url to wrap it in JSONP.
From the jQuery.getJSON docs:
$.getJSON("http://api.flickr.com/services/feeds/photos_public.gnetags=cat&tagmode=any&format=json&callback=?",
function(data){
$.each(data.items, function(i,item){
$("<img/>").attr("src", item.media.m).appendTo("#images");
if ( i == 4 ) return false;
});
});
Solution 2
I'm not sure how you're going to retrieve their data with Ajax, since Ajax doesn't work cross-domain.
Have you seen their $.getJSON demo? http://docs.jquery.com/Ajax/jQuery.getJSON
It lets you specify a callback and returns json wrapped as a parameter inside an automatically generated function. It works cross-domain as well.
Admin
Updated on February 02, 2020Comments
-
Admin about 4 years
I want to display whatever the response of flickr.test.echo was on the page using rest (jquery ajax - because thats what im using)
I need to supply an api_key
The REST Endpoint URL is http://api.flickr.com/services/rest/
To request the flickr.test.echo service, invoke like this:
http://api.flickr.com/services/rest/?method=flickr.test.echo&name=value
By default, REST requests will send a REST response.
To return the response in REST format, send a parameter "format" in the request with a value of "rest". When using the REST request method, the response defaults to REST.
A method call returns this:
[xml-payload-here]
If an error occurs, the following is returned:
I got that from here http://www.flickr.com/services/api/request.rest.html
This is the method I'm interested in http://www.flickr.com/services/api/flickr.test.echo.html
please help.