Javascript 根据搜索结果获取Flickr图像

Javascript 根据搜索结果获取Flickr图像,javascript,flickr,Javascript,Flickr,如何根据文件名显示Flickr中的某些图像。 我希望搜索图像并仅显示适合我的搜索结果的图像 老实说,这是我第一次使用Flickr,他们真的需要在那里放更多的例子 你知道从哪里开始吗?这是我集成的一个助手方法,可以让你向flickr的api发出请求。这可能会有助于浏览一下,这样您就可以开始了解如何处理您将要返回的数据。这应该可以在Chrome和Firefox中使用,我还没有在IE或Safari中测试过 /* * Make an XmlHttpRequest to api.flickr.com/s

如何根据文件名显示Flickr中的某些图像。 我希望搜索图像并仅显示适合我的搜索结果的图像

老实说,这是我第一次使用Flickr,他们真的需要在那里放更多的例子


你知道从哪里开始吗?

这是我集成的一个助手方法,可以让你向flickr的api发出请求。这可能会有助于浏览一下,这样您就可以开始了解如何处理您将要返回的数据。这应该可以在Chrome和Firefox中使用,我还没有在IE或Safari中测试过

/*
 * Make an XmlHttpRequest to api.flickr.com/services/rest/ with query parameters specified
 * in the options hash. Calls cb once the request completes with the results passed in.
 */

var makeFlickrRequest = function(options, cb) {
  var url, xhr, item, first;

  url = "http://api.flickr.com/services/rest/";
  first = true;

  for (item in options) {
    if (options.hasOwnProperty(item)) {
      url += (first ? "?" : "&") + item + "=" + options[item];
      first = false;
    }
  }

  xhr = new XMLHttpRequest();
  xhr.onload = function() { cb(this.response); };
  xhr.open('get', url, true);
  xhr.send();

};
用法:

var options = { 
  "api_key": "<your api key here>",
  "method": "flickr.photos.search", // You can replace this with whatever method,
                                  // flickr.photos.search fits your use case best, though.
  "format": "json",
  "nojsoncallback": "1",
  "text": "<your search text here>"  // This is where you'll put your "file name"
}

makeFlickrRequest(options, function(data) { alert(data) }); // Leaving the actual 
                                                            // implementation up to you! ;)

此方法与非jQuery版本具有相同的用法。

是否检查了此方法@克里斯,谢谢,我是克里斯,我来看看!其他人可以随意发布一些例子,如果你知道尼斯的解决方案…我将尝试使用你的一些代码,看看这将如何为我工作。我会再打给你的
var makeFlickrRequest = function(options, cb) {
  var url, item, first;

  url = "http://api.flickr.com/services/rest/";
  first = true;
  $.each(options, function(key, value) { 
    url += (first ? "?" : "&") + key + "=" + value;
    first = false; 
  });

  $.get(url, function(data) { cb(data); });

};