Flickr PHP search function

Flickr is probably the biggest photo treasury of user uploaded photos on the internet. Users are uploading high quality photos and writing titles, tags and descriptions, with which the visitors are told, what could be found on the photo they uploaded. Flickr uses this descriptions in their search engine and while it’s search form stands on the relatively “best seen” position on the page it is probably one of the most used functions.

Rich text is known by it’s non-static structure - including photos/videos and other media into text. I’ve written a small PHP class, howto search videos on YouTube - it’s time to do the same for photo search on Flickr.

Before we start using Flickr (Yahoo! Inc.) API’s we have to register and get their API KEY. Without API Key this function won’t work ..

Function:
flickr_search()

Usage:
flickr_search(SEARCH_QUERY, OUTPUT_LIMIT, API_KEY)

SEARCH_QUERY - keywords, with which function shall preform the search query
OUTPUT_LIMIT - number of output array’s
API_KEY - code with which you tell the Flickr API that you are actually a human

Output:

title - name of the photo
link - hyperlink to the photo on Flickr
img_square - image link, size: 75px x 75px
img_thumbnail - image link, size: 100px on longest side
img_small - image link, size: 240px on longest side
img_medium - image link, size: 500px on longest side
img_large - image link, size: 1024px on longest side
img_original - image link, original size

Output example:

array(
         “title” => “Dog”,
         “link” => “http://www.flickr.com/photos/00000000@N00/0000000″,
         “img_square” => “http://farm.static.flickr.com/0/0_s.jpg”,
         “img_thumgnail” => “http://farm.static.flickr.com/0/0_t.jpg”,
         “img_small” => “http://farm.static.flickr.com/0/0_m.jpg”,
         ”img_medium” => “http://farm.static.flickr.com/0/0.jpg”,
         “img_large” => “http://farm.static.flickr.com/0/0_b.jpg”,
         “img_original” => “http://farm.static.flickr.com/0/0_o.jpg”
);

Download:

- flickr.php.txt
- flickr.rar

Preview:

http://www.delavec.net/_flickr/

Insert the query string into the text input field, press Search Flickr button and system will return results - 10 photos from Flickr.

Napiši odgovor