views:

668

answers:

2

Hiya,

I'm trying to pull in images from Flickr using the phpFlickr library but the docs seem to be quite vague and the results aren't as good as i would like, i wonder if anyone can shed some light on my code (maybe i'm using the wrong syntax?).

It works for some queries mainly 1 word queries, i.e. if i send the $tag "inter" it will find some photos on inter, but if i send "Inter Milan FC" it will not, even though a flickr search http://www.flickr.com/search/?w=all&q=inter+milan+fc&m=text clearly shows lots of inter milan fc photos.

Below is my implementation of the phpFlickr function....

function flickr_feed ( $tag ) {
    $f = new phpFlickr("MY API KEY", "MY API SECRET");
    $tags = $f->photos_search(array("tags"=>$tag, "tag_mode"=>"any","per_page"=>"20"));
    $counter="0";
    foreach ($tags['photo'] as $photo) {
     if($counter =="0" || $counter =="5" || $counter =="10" || $counter =="15") { $first = " first"; } else { $first = ""; }
     echo '<div class="flickr-thumb'.$first.'">
       <a rel="nofollow" target="_blank" href="http://farm'.$photo['farm'].'.static.flickr.com/'.$photo['server'].'/'.$photo['id'].'_'.$photo['secret'].'.jpg" title="'.$photo['title'].'">
       <img src="http://farm'.$photo['farm'].'.static.flickr.com/'.$photo['server'].'/'.$photo['id'].'_'.$photo['secret'].'_s.jpg" alt="'.$photo['title'].'"></a>
      </div>';
     $counter++;  
    }
}

I am also open to using other means of getting images from flickr (and not just phpflickr), i merely want to send a search to flickr and get a list of images, ideally i can control the amount that come back! that's it really, a simple task that is proving quite difficult :(

A: 

i've resolved it...

$tags = $f->photos_search(array("text"=>$tag, "sort"=>"interestingness-desc","per_page"=>"20"));

Use "text" search rather than tags!

Shadi Almosri
A: 

Tags should be comma-separated according to Flickr's API docs. I checked out phpFlickr.php and they are basically just passing your parameters directly up to Flickr.

Flickr Service API

pix0r
i've resolved it but thanks for your time anyway! :)
Shadi Almosri