+20 张照片 flickr api
我正在尝试在 flickr feed 中获取 +20 张照片。在另一个论坛上,有人发布了以下代码作为答案。我在第 2-3 行插入了我的 API + setID,但它不起作用。
$(document).ready(function() {
var apiKey = ‘******I inserted my API here’;
var photoSetID = ‘********set ID’;
var jsonURL = 'http://api.flickr.com/services/rest/?method=flickr.photosets.getPhotos&extras=url_o&photoset_id=' + photoSetID +
'&per_page=500&api_key=' + apiKey + '&format=json&jsoncallback;=?';
$.getJSON(jsonURL, function(data){
$.each(data.photoset.photo, function(i,item){
var imgSrc = ‘http://farm’ + item.farm + ‘.static.flickr.com/’ + item.server + ‘/’ +
item.id + ‘_’ + item.secret + ‘_b.jpg’;
$(’ <img >’).attr(’src’, imgSrc).appendTo(’#images’);
});
});
});
我认为我的两个主要问题是 - 我在哪里用我自己的信息替换信息:
var jsonURL = 'http://api.flickr.com/services/rest/?method=flickr.photosets.getPhotos&extras=url_o&photoset_id=' + photoSetID + '&per_page=500&api_key=' + apiKey + '&format=json&jsoncallback;=?';
这段代码的目的是什么?
var imgSrc = 'http://farm' + item.farm + '.static.flickr.com/' + item.server + '/' + item.id + '_' + item.secret + '_b.jpg';
非常感谢,我对 Jquery 的理解有限,而且 flickr api 的文档对于初学者来说出奇的匮乏。
凯尔西
I am trying to get +20 photos in a flickr feed. On another forum, someone posted the following code as an answer. I inserted my API + setID in the lines 2-3, but it didn't work.
$(document).ready(function() {
var apiKey = ‘******I inserted my API here’;
var photoSetID = ‘********set ID’;
var jsonURL = 'http://api.flickr.com/services/rest/?method=flickr.photosets.getPhotos&extras=url_o&photoset_id=' + photoSetID +
'&per_page=500&api_key=' + apiKey + '&format=json&jsoncallback;=?';
$.getJSON(jsonURL, function(data){
$.each(data.photoset.photo, function(i,item){
var imgSrc = ‘http://farm’ + item.farm + ‘.static.flickr.com/’ + item.server + ‘/’ +
item.id + ‘_’ + item.secret + ‘_b.jpg’;
$(’ <img >’).attr(’src’, imgSrc).appendTo(’#images’);
});
});
});
I think my two main problems are- where in here do I replace the info with my own:
var jsonURL = 'http://api.flickr.com/services/rest/?method=flickr.photosets.getPhotos&extras=url_o&photoset_id=' + photoSetID + '&per_page=500&api_key=' + apiKey + '&format=json&jsoncallback;=?';
And what is the purpose of this code?
var imgSrc = 'http://farm' + item.farm + '.static.flickr.com/' + item.server + '/' + item.id + '_' + item.secret + '_b.jpg';
Thanks so much, my understanding of Jquery is limited and the documentation on flickr api is surprisingly scarce for beginners.
Kelsey
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
![扫码二维码加入Web技术交流群](/public/img/jiaqun_03.jpg)
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
转到 flickr 上的照片流页面,然后向下滚动到页面底部,其中显示“订阅用户的照片流”。单击橙色 RSS 源图标,然后您将找到照片流的源。在顶部地址会有一个类似于 49269824@N04 的 id,将其放入下面的代码中,然后将 id 为 flickr 的 div 添加到网页正文中。
您可以通过更改上面 if(i < 20){.... 中的数字来设置所需图像数量的限制。
祝你好运。
Go to your or the photostream page on flickr and scroll down to the bottom of the page where it says Subscribe to users's photostream. Click the on the orange RSS feed icon then you will find the feed for the photostream. At the top address there will be an id that looks like 49269824@N04 this, put that in the code below and add a div with an id of flickr to your body of you web page.
You can set a limit on how many images you want by changing the number in if(i < 20){.... in the above.
Good Luck.