To do this, you need a Filckr API key. Go to http://www.flickr.com/services/ to get details info.
I have done this to get my uploaded image and here I have used my API key.
function request($params){
$api_key = '9ab63850e3exxxxxxxxxxxxxxxxxxxxx';
$url = 'http://api.flickr.com/services/rest/?' .
'api_key=' . $api_key . '&format=php_serial';
foreach($params as $key => $val){
$url .= '&' . urlencode($key) . '=' . urlencode($val);
}
$resp = file_get_contents($url);
return unserialize($resp);
}
$params = array('method' => 'flickr.people.findByUsername',
'username' => 'shiblydu');
$user = request($params);
echo '
';';
print_r($user);
echo '
$params = array('method' => 'flickr.people.getPublicPhotos',
'user_id' => '42489449@N04'
);
$photos = request($params);
echo '
';';
print_r($photos['photos']['photo']);
echo '
$params = array('method' => 'flickr.urls.getUserPhotos',
'user_id' => '42489449@N04'
);
$url = request($params);
echo '
';';
print_r($url);
echo '
function build_photo_url($p){
return 'http://farm' . $p['farm'] . '.static.flickr.com/' . $p['server'] .
'/' . $p['id'] . '_' . $p['secret'] . '.jpg';
}
foreach($photos['photos']['photo'] as $pp){
// echo '
';';
// print_r($pp);
// echo '
//echo build_photo_url($pp);
echo '';
echo '
';
}
?>
No comments:
Post a Comment