Вот вспомогательный метод, который я собрал вместе, чтобы вы могли запросить api flikr. Вероятно, это поможет взглянуть на flickr api documentation, чтобы вы могли начать выяснять, как обрабатывать данные, которые вы получите. Это должно работать в 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, вот версия 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); });
};
Этот метод имеет тот же использование в качестве версии без JQuery.
Вы проверили это? http://mashupguide.net/1.0/html/ch08s07.xhtml – Chris
@ Крис благодарит Криса, я посмотрю на него! Другие вы можете отправить несколько примеров, если знаете –