PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Corey W.   Flickr API Wrapper   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example Usage
Class: Flickr API Wrapper
Send requests to the Flickr API
Author: By
Last change: added <?php for code highlighting
Date: 15 years ago
Size: 695 bytes
 

Contents

Class file image Download
<?php

$api_key
= 'your_flickr_api_key_here';

$flickr = new Flickr($api_key);

$params = array
(
   
'user_id' => 'your_flickr_user_nsid',
   
'extras' => 'url_m,url_sq',
   
'per_page' => 10,
);

$result = $flickr->call('people.getPublicPhotos', $params);

foreach (
$result->photos->photo as $photo)
{
   
$p = $flickr->call('photos.getInfo', array('photo_id' => $photo->id));

    echo
'<h2>'.$photo->title.'</h2>';
    echo
'<a href="'.$photo->url_m.'"><img src="'.$photo->url_sq.'" alt="" /></a><br />';
    echo
nl2br($p->photo->description->_content);
}

// Example using chaining

$result = Flickr::factory($api_key)->call('people.getPublicPhotos', $params);