2012-11-19 64 views
1

我需要將Google圖片搜索集成到我的網站,但我發現該API已被棄用。Google圖片搜索已棄用

因此,基本上我想建立一個集成的圖像搜索(無論我使用雅虎,谷歌,更重要?)添加和品牌標誌的無關緊要,只要用戶可以留在頁面上搜索圖像那裏。

有沒有其他的選擇?是否值得去棄用谷歌API?

這是我的示例代碼,今天仍然有效:

function getGoogleImages(query, userIp, callback) { 
    var url = 'https://ajax.googleapis.com/ajax/services/search/images?v=1.0&q=' + query + '&userip=' + userIp + '&callback=?'; 

    $.getJson(url, function(data) { 
    callback(data.responseData.results); 
    }); 
} 

    getImages('Horses', 'ip-goes-here', function(data) { 
    $.each(data, function(i, results) { 
     $('<img />').attr('src', results.unescapedUrl).attr('id', 'img' + i).appendTo('#images'); 
     $('#img' + i).wrap($('<a />').attr('href', results.unescapedUrl)); 
    }); 
    }); 

注:

我知道了鼓勵使用的API,但自定義搜索是不是我想要的東西,我要搜索在Google Images上(http://www.images.google.com)不在我的網站上。

+0

「的谷歌圖片搜索API已正式棄用5月26日,2011年將繼續按照工作我們我們建議您升級到[自定義搜索API](https://developers.google.com/custom-search/v1/overview),其中現在支持圖片搜索「 – mplungjan

+0

我知道這一點,但自定義搜索API只搜索我定位網站上的圖片,不在谷歌圖片上,所以它是完全不同的。 – onlineracoon

回答