Skip to content

Instantly share code, notes, and snippets.

@azharisubroto
Created February 1, 2016 16:23
Show Gist options
  • Save azharisubroto/f3964263eacfe5af5436 to your computer and use it in GitHub Desktop.
Save azharisubroto/f3964263eacfe5af5436 to your computer and use it in GitHub Desktop.
The final result from hours of googling, finally I can find this snippet.
<?php
// Read more API Documentation @ https://www.flickr.com/services/api/
$xml = simplexml_load_file("https://api.flickr.com/services/rest/?method=flickr.people.getPublicPhotos&user_id={YOUR USER ID}&per_page=[NUMBER OF PHOTOS TO FETCH]&api_key={REQUIRED!!! YOUR API KEY}&&format=rest");
$output = "<div>";
foreach($xml->children()->children() as $child) {
$imgsrc = "http://farm" . $child['farm'] . ".static.flickr.com/" . $child['server']. "/" . $child['id'] . "_" . $child['secret'] . "_s.jpg"; // More about image size suffixes: https://www.flickr.com/services/api/misc.urls.html
$fullsize = "http://farm" . $child['farm'] . ".static.flickr.com/" . $child['server']. "/" . $child['id'] . "_" . $child['secret'] . "_o.(jpg|gif|png)";
$output .= "<a href='".$imgsrc."'>";
$output .= "<img src='".$imgsrc."' />";
$output .= "</a>";
}
$output .= "</div>";
echo ($output);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment