简体   繁体   中英

How to to send and retrieve data from flickr flickr.test.echo method using JQuery Ajax REST?

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.

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.

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;
      });
    });

I would just use the jQuery-Flickr plugin , a lot easier! :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM