Flickr API -

Posted on 2009-02-22
Last Modified: 2012-05-06
Hi, I want to show photos in my page from flickr.
I get the API key, and I going to one page that show the arguments of the method '' (
When I call the method the system give me this results:
  <?xml version="1.0" encoding="utf-8" ?>
- <rsp stat="ok">
- <photos page="1" pages="409880" perpage="5" total="2049400">
  <photo id="3299837581" owner="13605215@N03" secret="7e419a7e7f" server="3463" farm="4" title="Labradors" ispublic="1" isfriend="0" isfamily="0" />
  <photo id="3299833035" owner="13605215@N03" secret="68220f9825" server="3618" farm="4" title="American Rottweiler" ispublic="1" isfriend="0" isfamily="0" />
  <photo id="3299828965" owner="13605215@N03" secret="0b0a4283fa" server="3624" farm="4" title="German Rottweiler" ispublic="1" isfriend="0" isfamily="0" />
  <photo id="3299818615" owner="57838910@N00" secret="1be93d9069" server="3470" farm="4" title="Sophia" ispublic="1" isfriend="0" isfamily="0" />
  <photo id="3299795245" owner="35052628@N00" secret="1a842d13bd" server="3517" farm="4" title="Layla lookin TOUGH" ispublic="1" isfriend="0" isfamily="0" />
and give me this URL:
If I want to show that 5 photos about dogs and cats in php, how I do?
Regards, JC  
Question by:Pedro Chagas
    LVL 19

    Accepted Solution

    LVL 3

    Author Comment

    by:Pedro Chagas
    hi, i see the example in the page you send to me.
    i have one doubt, where i get the file phpFlickr.php or what i put inside of the file.
    regards, jc
    LVL 19

    Expert Comment

    phpFlickr.php is available for download at flickr, as linked in the example page given. All the source code is there to tinker with.
    LVL 3

    Author Comment

    by:Pedro Chagas
    I do the download and I install PEAR module of flickr in my server. I create a folder that contain entire files of the download, the folder call "phpFlickr", because in example have this line require_once("phpFlickr/phpFlickr.php");

    Have one file that call auth.php, and I put inside my keys of flickr.
    I try to execute index.php (view code snippet), and I get this phrase:
    "DB Error: connect failed".

    I need a database? For what?
    I don't want photos from a username, I want get photos from a search (

    What is the next step?

    Regards, JC
    // Create new phpFlickr object
    $f = new phpFlickr("[API Key]");
    $i = 0;
    if (!empty($_POST['username'])) {
        // Find the NSID of the username inputted via the form
        $person = $f->people_findByUsername($_POST['username']);
        // Get the friendly URL of the user's photos
        $photos_url = $f->urls_getUserPhotos($person['id']);
        // Get the user's first 36 public photos
        $photos = $f->people_getPublicPhotos($person['id'], NULL, 36);
        // Loop through the photos and output the html
        foreach ((array)$photos['photos']['photo'] as $photo) {
            echo "<a href=$photos_url$photo[id]>";
            echo "<img border='0' alt='$photo[title]' ". //>
                "src='" . $f->buildPhotoURL($photo, "Square") . "' />";
            echo "</a>";
            // If it reaches the sixth photo, insert a line break
            if ($i % 6 == 0) {
                echo "<br />n";
    <h3>Enter a username to search for</h3>
    <form method='post'>
        <input name='username'/><br />
        <input type='submit' value='Display Photos'/>

    Open in new window

    LVL 19

    Expert Comment

    "I want to show photos in my page from flickr"
    "I don't want photos from a username, I want get photos from a search"

    So which is it? In the original question you wanted to display images from your flickr page. Now you want to search flickr?

    Your other questions are answered in the comments of the source code. You need to store the resulting images in EITHER a database or the file system.

    After your last post, it's obvious that you want to do up a flickr search engine. The api is not going to help you there. Even the search method in the flickr object requires you to state which flickr user account/s to search.
    LVL 3

    Author Comment

    by:Pedro Chagas
    Hi, In the title of this question I put '', and I thing this is the method for do what I want, if isn't, I'm sorry about my ignorance.

    What I want not is a pure search engine, but something like.
    I develop a project, and the objective of this project is you write a 'title' in the box, like: "The best print paper", and the system go check the web (between 1 -  2 minutes), and the result is a report about "The best print paper", I give you the best title I found in the NET, the words more write in all web sites I check, I give information about some important html tags, and so on.
    So, if you see one, just one report, you like, but after 10.000 reports (or 10.000 titles) it's always words, seems like the same thing for 10.000 results.
    So I thing, I go put more beauty things in each report, and image helps. I want give 3 or 4 photos about the+best+print+paper or another title customer search. In this way I produce more beautiful reports pages, and not seems the same thing.

    Do you thing this is the write way to put my reports most different? Have another solution (if it is impossible in flickr)?

    The best regards, JC
    LVL 19

    Assisted Solution

    Even if it's possible, I don't think it's legal. You're using flickr as a source of image information in an automated information retrieval system. Typically this is expressly forbidden in copyrighted materials. You'd have to read the terms and conditions to find out if it's legal before going to all the trouble of making it possible.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
    These days socially coordinated efforts have turned into a critical requirement for enterprises.
    The viewer will learn how to count occurrences of each item in an array.
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now