Download flickrfuncs.php
Version 1.0 - PHP File, 8.5 KB
Version 1.0
  • Initial Release

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

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.

100_2253 100_1130 100_1201 100_2156 100_1134 Filey Sea 100_1381 100_1009

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:

Real World Formatting Examples

Getting the script to work with Lightbox2

$Formatting = '<a rel="lightbox" href="[big]"><img src="[square]" alt="[title]"/></a>';