This demo shows you how to retrieve today’s top rated photos from Flickr as the most recent uploads using jQuery and phpFlickr.
Tutorial: Flickr Photo Gallery
Previous post: Yahoo! Releases YUI 2.6.0
Next post: Build Your First Ext-JS in Under an Hour
{ 4 comments… read them below or add one }
Hi, this looks fantastic. Thank you for going into so much detail with it. I was actually looking for code which would pull in photos from a particular gallery which I uploaded to Flickr. Is there a way to adapt this script to do that?
Vicki, I am glad you found this tutorial helpful.
The short answer is that you can use the photosets_getPhotos() method, which will accept a photosetid.
In proxy.php, replace the line:
$f->photos_getRecent( null, $_perPage, 1 )with:
$f->photosets_getPhotos(photosetid, null, null, $_perPage);and make sure to pass in a valid photosetid. You can look it up by visiting a public photoset like this one of mine, and extracting the ID from the URL. In this case 72157612712643487.
I hope this helps.
Great tutorial,
Even though I have come across it a year later I hop you can help.
I have the same issue as Vicky. I need to use the photosets_getPhotos() method to grab my set from flickr.
I have tried your solution like this -
$photoset_id = "72157612712643487";$photos = ( $_GET['recent']==='true' )
? $f->photosets_getPhotos($photoset_id, null, null, $_perPage)
: $f->interestingness_getList( null, null, $_perPage )
;
The result is the same as before where it displays a list of interesting photos for the most recent day.
Am I leaving out something really obvious?
The code below is a ternary operation that checks the radio button selection and loads one of two possible datasets, most popular or your photoset.
$photos = ( $_GET['recent']==='true' )? $f->photosets_getPhotos($photosetid, null, null, $_perPage)
: $f->interestingness_getList( null, null, $_perPage )
;
The default selection is most popular/interesting photos. If you’re using the entire code in the example, just click on the radio button that reads “Most Recent” and your photoset will be loaded instead.
If your own code doesn’t need to switch between these datasets, just execute the following instead of the code block above.
$photos = $f->photosets_getPhotos($photosetid, null, null, $_perPage);Note: While this will display the thumbnails correctly, the links will be broken since the “photo” object in the dataset doesn’t contain the “owner” property. Instead it’s found once in the metadata. The result is a broken link.
Because of this issue I have decided to update the sample code. After looking at the Flickr API I realized you can request additional data via the “extras” attribute for each method. I request “path_alias” in order to get around the missing “owner” property and use it in the JSON/HTML parsers.
Please take a look. I hope this helps.