Welcome Guest, Not a member yet? Register   Sign In
Flickr API Library
#1

[eluser]Jose Dueñas[/eluser]
Hi!
I'd like to announce you, I've developed a Flickr API library for CodeIgniter. Not all the method are supported yet, but all those don't need authentication are fully supported.

I've published the library in my blog (spanish language) but all you need to do is:

1) Copy the Flickr.php file into the 'system/applications/libraries' folder.
2) To call a method, for example 'flickr.photos.getInfo', you have to put in your controller:
Code:
$this->flickr->call('flickr.photos.getInfo', array('photo_id'=>2991976622));

It's the same way for all the methods, first argument is the method itself, and the second parameter is an associative array containing all the method parameters.

- You can download the library from here.

- The documentation (in spanish, I will translate into english soon): Documentation for the Flickr API Library.

- You will find all the methods and parameters in the Flickr API documentation.

I hope you will find this useful!
Jose Dueñas
#2

[eluser]cliffoliveira[/eluser]
How to display multiple photos?
#3

[eluser]Jose Dueñas[/eluser]
Hi Cliff,
the way you show a photo is:

Code:
$this->load->library('flickr');
    
$photo = $this->flickr->call('flickr.photos.getInfo', array('photo_id'=>2991976622));
    
if($photo['stat']=='ok')
{
    $farm      = $photo['photo']['farm'];
    $server  = $photo['photo']['server'];
    $id      = $photo['photo']['id'];
    $secret  = $photo['photo']['secret'];
        
    echo "Title: ".$photo['photo']['title']['_content'];
    echo "<br />";
    echo "<img src='http://farm".$farm.".static.flickr.com/".$server."/".$id."_".$secret."_m.jpg' />";
        
}else{
    echo "Oh my god! There was an error!";
}

So if you want to show several photos you have to use an array. For example, I suppose yo want to show the photos with the id's: 1000, 1001 and 1003.

You have to do (I haven't checked):
Code:
$this->load->library('flickr');
    
$photos[0] = ($this->flickr->call('flickr.photos.getInfo', array('photo_id'=>1000));
$photos[1] = ($this->flickr->call('flickr.photos.getInfo', array('photo_id'=>1001));
$photos[2] = ($this->flickr->call('flickr.photos.getInfo', array('photo_id'=>1002));
    
for(i=0;i<=2;i++)
{
     if($photos[i]['stat']=='ok')
     {
    $farm      = $photo['photo']['farm'];
    $server  = $photo['photo']['server'];
    $id      = $photo['photo']['id'];
    $secret  = $photo['photo']['secret'];
        
    echo "Title: ".$photo['photo']['title']['_content'];
    echo "<br />";
    echo "<img src='http://farm".$farm.".static.flickr.com/".$server."/".$id."_".$secret."_m.jpg' />";
        
     }else{
    echo "Oh my god! There was an error!";
     }
}

I hope this help you.
Regards,
Jose Duenas
#4

[eluser]cliffoliveira[/eluser]
and if I need to show all pictures of a particular album flickr?
could not generate an array already bringing all the photos from this album?
#5

[eluser]Jose Dueñas[/eluser]
So, you should use another different call to the api flickr: flickr.photosets.getPhotos
You can check the different calls (methods api) you can make in: http://www.flickr.com/services/api/

Regards,
Jose
#6

[eluser]cliffoliveira[/eluser]
Lamento abusar de su buena voluntad
pero todavía no puede tener éxito en el proceso de llamar a todas las fotos usando el siguiente método:
$lista = $this->flickr->call('flickr.photosets.getList', array('api_key'=>'*****'));
ele retorna um erro de identificação do usuário:

Array ( [stat] => fail [code] => 1 [message] => User not found )
utilizar ese formato?
#7

[eluser]Jose Dueñas[/eluser]
You have to provide 2 parameters, the first is the API key and the second the user_id of the user you want to get photos.
$lista = $this->flickr->call(‘flickr.photosets.getList’, array(‘api_key’=>’*****’,'user_id'=>'*********'));

Actually, the user_id is optional, but if you don't provide one, the calling user is assumed (but you have to authenticate first).

Espero que te sea de ayuda.
Jose
#8

[eluser]cliffoliveira[/eluser]
Perfect
thank you my friend
as my wife says: Who does not know is the same as he has not seen!
Thank you for helping me see
#9

[eluser]cliffoliveira[/eluser]
Although you can retrieve data from flickr, I'm still having a problem, call the function only returns when a single photo.
I can not bring all the images that are on site
$lista = $this->flickr->call('flickr.photosets.getList', array('api_key'=>'**','user_id'=>'**'));
print_r($lista );

how to call data to bring all the images?
#10

[eluser]Scott Boyde[/eluser]
[quote author="cliffoliveira" date="1255412922"]Although you can retrieve data from flickr, I'm still having a problem, call the function only returns when a single photo.
I can not bring all the images that are on site
$lista = $this->flickr->call('flickr.photosets.getList', array('api_key'=>'**','user_id'=>'**'));
print_r($lista );

how to call data to bring all the images?[/quote]

Cliff are you still having a problem with this.




Theme © iAndrew 2016 - Forum software by © MyBB