1
votes

Im trying to get random public images from flickr but i get an error, and dont know why? It is a very simple query, but something seems wrong:

    $.ajax({
        url: 'http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key=my_super_secret_key&tags=Netherlands&per_page=3&format=json',
        type: "GET",
        dataType: "json",
        success: function (data) {
            console.log("flickr");
            console.log(data);
        },
            error: function(xhr, status, error) {
                console.log("Error flickr");
                var err = ("(" + xhr.responseText + ")");
                console.log(err);
                console.log(status);
                console.log(error);
            }
    });

of course the super secret key is filled in, so that is not an error:)

error response is:

Error flickr (index):81 (jsonFlickrApi({"photos":{"page":1, "pages":680998, "perpage":3, "total":"2042994", "photo":[{"id":"12743757394", "owner":"95983323@N05", "secret":"6e8229d323", "server":"3736", "farm":4, "title":"Gorinchem", "ispublic":1, "isfriend":0, "isfamily":0}, {"id":"12743426273", "owner":"41159332@N02", "secret":"de25f48cf9", "server":"2867", "farm":3, "title":"Little beauty", "ispublic":1, "isfriend":0, "isfamily":0}, {"id":"12743767144", "owner":"93254204@N00", "secret":"43f58e5635", "server":"2824", "farm":3, "title":"...Of AmsterSam", "ispublic":1, "isfriend":0, "isfamily":0}]}, "stat":"ok"})) (index):83 parsererror (index):84 SyntaxError {stack: (...), message: "Unexpected token j"}

update:

ok found out need to pass parameter

nojsoncallback=1 but is it only possible to get thumbnails from the response?

1

1 Answers

1
votes

it seems that you simply forgot to add your api_key so your url should be

    url: 'http://api.flickr.com/services/rest/?method=flickr.photos.search&api_key='+my_super_secret_key+'&tags=Netherlands&per_page=3&format=json'

I just checked the url including my api_key and everything went fine.