PHP Addicted To Flickr API Class
September 14th, 2005
Lately I have become infatuated with Web Services, particularly of the REST format. I am also an avid user of Flickr, the best online photo sharing service. I currently show my flickr photos on my website using a Wordpress plugin written by Ramon Darrow. The plugin does an ok job, but I wanted to show things a bit differently than the plugin so decided to create my own.
Parting The Waters
My only problem with the aforementioned plugin is the lack of separation in retrieving the data and displaying the data. Because the two are intermingled throughout the plugin, it makes it difficult to change the layout and functionality. In order to achieve separation, I decided to write a Flickr API class to retrieve the data. Each method in the Flickr class returns an array of data which can then be used to display results however you dang well please. Despite the fact that I have not finished the Wordpress plugin, I have decided to release the Flickr API class for those who are interested.
Where Can I Get My Hands On It?
How the..? .What the…?
Wondering how to use it all? I have created a documentation mini-site with code samples, xml results, function returns and example outputs for each method that hits Flickr. Also, the class is well documented so if you aren’t afraid of a thousand lines of code, dive in. The cool thing about the documentation site is that all the code samples are executed on the page and you can see the example outputs based on the code live. The requests are all cached using the enableDBCache(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) method, so refresh away.
Support
Any questions, bugs and feature requests can be entered in the comments or by using my contact form.
Donate
Also, if you like this class, feel free to make a donation using the button below. Donations inspire me to add features and improvements and create more free handy tools.
If you enjoyed this post, get free updates by email or RSS.

Great site! Awesome layout, just awesome. When can we expect the plugin? Newbs like me need all the help we can get.
@Jayson - I would expect the plugin should be done in a few weeks. I know that’s general, but I have quite a few ideas that I am working on right now. Thanks for the nice comments.
Looks like a solid piece of work, and what a lovely documentation site! Looks like I’m gonna be addicted to this one for a while…
Nice work! a lot more simple to use than others!
Some suggestions to the documentation:
Tell user that they will nead a Mysql database with username and password.
Eg. at “Get group info”
/* Change DB_HOST to localhost or the host address to your MySQL database server
Change DB_USER and DB_PASSWORD to your MySQL login values. Create a empty database and change DB_NAME to the database name
*/
$flickr->enableDBCache(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
Tell the users how to get the ID that is neaded to seache for pictures.
eg.
/* 89776093@N00 is an example ID for a group. You will find the group ID at the feed link on the group pages (www.flickr.com)
*/
$group_info = $flickr->getGroupInfo(’89776093@N00′);
52239735206@N01
Current timestamp is 8bb0234681aa6652e8500b1144c6dadb
Nice!! Here’s some interesting material as well: http://www.newwebplatform.com/tips-and-tutorials/Flickr
I love it. See http://listenlight.net/dev/16/magi for a basic template planned for issue 16 at http://listenlight.net. My only question is on the db cacheing.. how does it improve performance? The tags I query are mainly common, e.g., colorful, summer, beach, flowers, etc., the photos of which are likely to update very quickly at flickr. With that in mind, I pass a random number for the page result. Any comments welcome.
Also, I see your latest blog entry on your having left a regular job for Wild West 2.0
The following is compulsory :-)
http://programmermeetdesigner.com/listing/view/2654
@Jesse - DB Caching doesn’t improve performance it just keeps you from getting banned by flickr for hitting their api too much.
John - thanks for the awesome class!
Question - I have it set to use enableFSCache, but each cache file is being overwritten by any subsequent lookups. I have my cache set to expire at 3600 seconds.
Example -
UserA ->Cachefile01
UserB ->deletes Cachefile01 and writes Cachefile02
UserA -> deletes Cachefile02 and writes Cachefile03
Any ideas on why it isn’t keeping the individual cache files?
Thanks!
@Craig - Haven’t written php in several years. Sorry. I don’t know that I ever really tested the file system cache that much. Just use the db cache. I know it works as that is what I typically used.
How can I show my favorite photo list? I mean, how should I modify the code to get it?
If this class is not supported, could you recommend a class? Thanks!
If it is not currently in the library already then you are out of luck. I haven’t touched it in probably 3 years. I don’t know of any others as I’m no longer in the php community.