Description
A simple PHP Flickr badge code parser. Why use the badge code instead of the Flickr API? Because it allows you to pull photos from your Flickr account in a random order, and lets you embed them without the use of JavaScript, and you can get the code to work with JavaScript lightbox scripts.
Contents
Requirements
- Some knowledge of HTML (CSS for further customization)
- Your Flickr ID - http://idgettr.com/
- A server running PHP v5+ (Untested on any lower versions)
Code Example
To start using the Badge API, follow the steps below to setup the example script. This will teach you the basics of using it, and you can customize it using the layout that you decide.
1. Create a new PHP file. Call it something like test.php.
2. Replacing FLICKR_ID with your Flickr ID, copy the code below into the new file.
// The Flickr ID you want to get data for.
$FlickrID = '8841574@N05';
// Custom Formatting. In the example below, [page] is converted into the photo page URL
// on flickr, [title] into the photo title and [square] into the URL of the image file.
$Formatting = '<a href="[page]"><img src="[square]" alt="[title]"/></a>';
// Number of photos you want to show (Leave blank for maximum)
$Number = '8';
// Sort order - display at "random" or display "latest" photos?
$Display = 'random';
include('flickrfuncs.php');
flickrdata($FlickrID,$Formatting,$Number,$Display);
?>
3. Upload test.php and the downloaded flickrfuncs.php to the same folder on your server, and open up test.php in your browser. You should see 4 photos all linked to the respective page on Flickr. The page will look something like the below, with the 8 photos replaced by your account's photos.
Documentation
As above, the text in square brackets is replaced by the appropriate data, so [title] is replaced by the title of the photo.
There are several formatting options to pick from:
- [count] - A count value, used to identify the result number
- [page] - The URL to the photo's page on Flickr
- [original] - The URL to the original photo file
- [big] - The URL to a big version of the photo file
- [medium] - The URL to a medium version of the photo file
- [small] - The URL to a small version of the photo file
- [thumbnail] - The URL to a thumbnail version of the photo file
- [square] - The URL to a 75 pixel square version of the photo file
- [title] - The title/name of the photo
Real World Formatting Examples
Getting the script to work with Lightbox2








