how to display your flickr photos using php

A Division of Me by toxictwo on deviantART
Photo by ~toxictwo on deviantART

In order to complete this tutorial you will need to apply for a flickr API key. You will also need to download a copy of phpFlickr API Kit. The use of an API Kit makes the use of flickr’s API methods easier. You can also view the demo page of the tutorial (opens in a new tab).

Let’s begin. First, we need to include the phpFlickr main file and then create a new phpFlickr object which is stored in the $phpFlickrObj variable. Make sure you enter the correct path (where you extracted the phpFlickr files) and also enter your flickr API key.

require_once("phpFlickr/phpFlickr.php");
$phpFlickrObj = new phpFlickr('Your_Flickr_API_Key');

The next step is to obtain your NSID by using your flickr username (in the example I’m using my flickr username), which is stored in the $user variable. Using this NSID, we get the url to the specific user’s photos and we store it in the $user_url variable. Finally, we get an array ($photos) containing all the relevant information (id, title, etc.) of the last four (if you want to change the number of photos, just change the number) photos appearing in the user’s photostream.

$user = $phpFlickrObj->people_findByUsername('stathisg');
$user_url = $phpFlickrObj->urls_getUserPhotos($user['id']);
$photos = $phpFlickrObj->people_getPublicPhotos($user['id'], NULL, NULL, 4);

In this example we use only the id and the title of each photo. If you want to view all the information contained in the array, you can use print_r($photos).

The final step to display the photos, is to convert the multidimensional array into an array of one dimension and use a loop to display everything. The following code, displays the photos. The photos can be displayed in six different sizes. To change the size, you need to alter the “square” value. The available sizes are: square, thumbnail, small, medium, large and original.

foreach ($photos['photos']['photo'] as $photo)
{
  echo '<a href="'.$user_url.$photo['id'].'" title="'.$photo['title'].' (on Flickr)" target="_blank">';
  echo '<img alt="'.$photo['title'].'" src="'.$phpFlickrObj->buildPhotoURL($photo, "square").'" />';
  echo '</a>';
}

The complete code is diplayed below. You can also view the demo page of the tutorial (opens in a new tab).

require_once("phpFlickr/phpFlickr.php");
$phpFlickrObj = new phpFlickr('46dea5f6abb12aed7a823adb7ecf5816');

$user = $phpFlickrObj->people_findByUsername('stathisg');
$user_url = $phpFlickrObj->urls_getUserPhotos($user['id']);
$photos = $phpFlickrObj->people_getPublicPhotos($user['id'], NULL, NULL, 4);

foreach ($photos['photos']['photo'] as $photo)
{
  echo '<a href="'.$user_url.$photo['id'].'" title="'.$photo['title'].' (on Flickr)" target="_blank">';
  echo '<img alt="'.$photo['title'].'" src="'.$phpFlickrObj->buildPhotoURL($photo, "square").'" />';
  echo '</a>';
}
 

a collection of useful android applications

Android by fetuscakemix on deviantART
Creation by ~fetuscakemix on deviantART

Recently, I acquired an android Smartphone and while browsing in several android forums and the android market, I discovered the following useful applications:

GmoteGmote: An amazing application that turns Android into a remote control for a computer, allowing users to run movies and music at a distance. It supports all of the standard remote control features such as play, pause, rewind, volume controls etc. It also has a built-in file browser that lets you select what to play.

tasKillerTasKiller free: Let you close (kill) any running application in one click.

batteryLifeBatteryLife: Displays the percent of the remaining battery.

powerManagerPower manager: Adds new power settings to the phone (e.g. how long the screen is on during a call, if device stays on while the keyboard is open, etc.) and allows you to quickly view and change other phone settings depending on different conditions (e.g. low battery).

quickUninstallerQuick Uninstaller: Uninstalls applications from the phone using a desktop-style view. The uninstall is performed by only two clicks.

anyCutAny Cut: Allows you to create Home shortcuts to anything! Popular shortcuts like directly calling a phone number or sending an SMS are supported.

Some of the applications listed here have also a paid version, but this post refers only to their free versions.

 

demon hunter – heroes of might & magic V custom map

Demon Hunter by ZanBon
Photo by ZanBon

A good friend of mine created this great custom map for the Heroes of Might & Magic V strategy game. Read the description and give it a try:

“The Demon Sovereign has settled for many years in a distant underground castle, planing a fierce unleash of his army on the world. Strong magic has trapped the demon within his castle for over two centuries but now he has discovered a way out. It is time to stop him once and for all. Conquer any other claimer of the title because you only shall be remembered as the Demon Hunter!”

Download Link: Demon Hunter by ZanBon