phpflickr = new phpFlickr($apikey); $this->username = $username; $userinfo = $this->phpflickr->people_findByUsername($username); $this->usernsid = $userinfo["nsid"]; } function getPhotos() { $res = $this->phpflickr->people_getPublicPhotos($this->usernsid); return $res["photos"]["photo"]; } } class photoFlickr { protected $width; protected $height; protected $img; protected $link; protected $details; protected $phpflickr; //Takes the array of photo data provided by Flickr for a given image function photoFlickr($photo, $apikey) { $this->details = $photo; $this->phpflickr = new phpFlickr($apikey); $this->img = sprintf('http://farm%d.static.flickr.com/%d/%s_%s.jpg', $photo["farm"], $photo["server"], $photo["id"], $photo["secret"]); $this->link = sprintf('http://www.flickr.com/photos/%s/%s', $photo["owner"], $photo["id"]); } //Return the IMG SRC HTML tag for the image, with it linked to the Flickr page if $linked==true. function getHTML($linked=true) { $output = sprintf('%s', $this->img, $this->getTitle(), $this->width, $this->height); if ($linked) $output = sprintf('', $this->link) . $output . ''; return $output; } //Given a width, and possibly a height, compute what size of image to request from Flickr, // and also what width and height dimensions to display it at. function setSize($width, $height=null) { $this->width = $width; $sizeinfo = $this->phpflickr->photos_getSizes($this->details["id"]); foreach ($sizeinfo as $size) { if ($size["width"] >= $width) { $sizeinfo = $size; break; } } $this->img = $sizeinfo["source"]; if (empty($height)) { $ratio = $width / $size["width"]; $this->height = $size["height"] * $ratio; } else { $this->height = $height; } } function getTitle() { return $this->details["title"]; } } ?>