Json and Flickr API
I've gone through the http://css-tricks.com/examples/BuildYourSocialPage/ which is great, but I just want to customise the amount of Flickr images it pulls in(6) with the API.
I know I could set a div with overflow:hidden to show the desire开发者_StackOverflow中文版d amount, but I don't want the code to be hacky.
Can anyone help?
Also I'd like to display my last.fm latest albums, does anyone know where you can get the API to do this?
Thanks
Paul
P.S I know you can get premade plugins and do all this through wordpress, but I don't want to do that. It's just a small expirmental page to test ideas.
One thing to note is that the example page is not actually using the full-on Flickr API -- it's using a simple feed to retrieve the photos.
This gives less control -- I believe the number of items from these feeds are fixed at 20.
I can think of a few different ways you can go from here.
You could:
- Filter the results you get back in JavaScript to throw away the unwanted images. Probably easiest, but a bit inelegant.
- Use the Flickr API instead, which will allow you to set limits, but will require an API key, and is probably easier server-side.
- Use something like YQL to do your Flickr search and limiting, and parse those results instead. I created an example query here. YQL allows JSONP, so you could still use this cross-domain, I believe, though you'd need to change the receiving Javascript to match the new format. There's an excellent example of using YQL to search Flickr on the Wait till I come site.
- Create a Yahoo Pipe to truncate the feed for you, perhaps grabbing it as RSS, feeding it through the Pipe's RSS-fiddling functions, and spitting out JSONP -- I believe this is doable in Pipes.
YQL in particular is very cool and very powerful, especially when dealing with Yahoo's own services like Flickr. Seeing as you say you're playing with ideas, I figured I'd give you some interesting ones to play with :)
The Flickr Feeds Service do not allow such parameterization, but you could change the JavaScript code that displays them to filter only the first 6
$.each(data.items, function(index, item){ if (index < 6){ $("<img/>").attr("src", item.media.m).appendTo("#flickr") .wrap("<a href='" + item.link + "'></a>");} });
Last.fm Api => user.getWeeklyAlbumChart
精彩评论