簡體   English   中英

查詢Flickr API

[英]Querying flickr api

我試圖從flickr中獲取隨機的公共圖像,但出現錯誤,不知道為什么? 這是一個非常簡單的查詢,但似乎有問題:

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

當然,超級秘密密鑰已填寫,因此這不是錯誤:)

錯誤響應是:

錯誤flickr(索引):81(jsonFlickrApi({“ photos”:{“ page”:1,“ pages”:680998,“ perpage”:3,“ total”:“ 2042994”,“ photo”:[{“ id “:” 12743757394“,”所有者“:” 95983323 @ N05“,”秘密“:” 6e8229d323“,”服務器“:” 3736“,”農場“:4,”標題“:” Gorinchem“,” ispublic“: 1,“ isfriend”:0,“ isfamily”:0},{“ id”:“ 12743426273”,“所有者”:“ 41159332 @ N02”,“秘密”:“ de25f48cf9”,“服務器”:“ 2867”, “農場”:3,“標題”:“小美女”,“ ispublic”:1,“ isfriend”:0,“ isfamily”:0},{“ id”:“ 12743767144”,“ owner”:“ 93254204 @ N00”,“秘密”:“ 43f58e5635”,“服務器”:“ 2824”,“農場”:3,“標題”:“ ... AmsterSam”,“ ispublic”:1 、、“ isfriend”:0,“ isfamily“:0}]},” stat“:” ok“})))(索引):83 parsererror(索引):84 SyntaxError {stack:(...),消息:”意外令牌j“}

更新:

確定發現需要傳遞參數

nojsoncallback = 1,但是只能從響應中獲取縮略圖嗎?

看來您只是忘了添加api_key,因此您的網址應為

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

我剛剛檢查了包括我的api_key在內的網址,一切正常。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM