Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3284680
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:10:53+00:00 2026-05-17T20:10:53+00:00

I’m trying to use my Flickr account as a ‘host’ for an image gallery.

  • 0

I’m trying to use my Flickr account as a ‘host’ for an image gallery. I’ve tagged 251 photos with a common tag ‘golftournament’ and each one with the year and any players in the photo.

So, for example, three random photos may have the following tags:

golftournament dan steve 2005 (dan and steve in this photo from 2006)

golftournament 2006 (no players in this photo from 2006)

golftournament 2008 paul dan (paul and dan in this photo from 2008)

When I make an API call, it returns an inconsistent total number of photos if I set the ‘tags’ part of the API call to tags=golftournament,dan,2005 and the tag_mode to tagmode=all.

Sometimes I get 13 photos in the result, sometimes I get 12 photos and sometimes I actually get the correct number of photos (14)

I’m using a PHP library, but that’s irrelevant because I see the same results in the Flickr API Explorer: http://www.flickr.com/services/api/explore/?method=flickr.photos.search)

Is there any reason why the Flickr API is so inconsistent in this regard?

Cheers,

Dan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T20:10:54+00:00Added an answer on May 17, 2026 at 8:10 pm

    Just to update on this, in the end I simply got all photos from a photoset and then built two arrays of years and players from the tags. Finally, I used what the request was to return the correct photographs. I’m using the excellent phpFlickr library and here’s my entire API script:

    <?php
    // Initialise Flickr API library and authentication
    require_once("phpFlickr.php");
    $f = new phpFlickr('<api key>', '<secret>');
    $f->setToken('<token>');
    
    // Get all photos from the photoset
    $page = 0;
    $perpage = 500;
    $all = array('photos' => array(), 'total' => 0);
    while ($perpage * $page < $all['total'] || $all['total'] == 0) {
        $p = $f->photosets_getPhotos('<photoset number>', 'tags', NULL, $perpage, $page + 1);
        $all['total'] = (integer) $p['photoset']['total'];
        $all['photos'] += $p['photoset']['photo'];
        $page++;
    }
    
    // Get all the available years/players from the tags
    $years = array();
    $players = array();
    foreach ($all['photos'] as $key => $photo) {
        $photo_tags = explode(' ', $photo['tags']);
        $all['photos'][$key]['tags'] = $photo_tags;
        foreach ($photo_tags as $tag) {
            if (preg_match('/^[0-9]{4}$/', $tag)) {
                if (!in_array($tag, $years)) {
                    $years[] = $tag;
                }
            } else {
                if (!in_array($tag, $players)) {
                    $players[] = $tag;
                }
            }
        }
    }
    rsort($years);
    sort($players);
    
    // Set year/player tags if set
    $tags = array();
    if (isset($_GET['year']) && in_array($_GET['year'], $years)) {
        $tags['year'] = $_GET['year'];
    }
    if (isset($_GET['player']) && in_array($_GET['player'], $players)) {
        $tags['player'] = $_GET['player'];
    }
    
    // Build output array and filter by year/person
    $output = array(
        'years'     => $years,
        'players'   => $players,
        'photos'    => array()
    );
    foreach ($all['photos'] as $key => $photo) {
        if (!isset($tags['year']) || in_array($tags['year'], $photo['tags'])) {
            if (!isset($tags['player']) || in_array($tags['player'], $photo['tags'])) {
                $output['photos'][] = array(
                    'thumbnail' => $f->buildPhotoURL($photo, 'Square'),
                    'image'     => $f->buildPhotoURL($photo, 'Large'),
                    'tags'      => implode(' ', $photo['tags'])
                );
            }
        }
    }
    $output['totals']['total'] = count($output['photos']);
    
    // Calculate paging
    $output['perpages'] = array(32, 64, 128, 256);
    if (isset($_GET['perpage']) && in_array($_GET['perpage'], $output['perpages'])) {
        $output['perpage'] = $_GET['perpage'];
    } else {
        $output['perpage'] = $output['perpages'][0];
    }
    if ($output['totals']['total'] <= $output['perpage']) {
        $output['pages'] = 1;
    } else {
        $output['pages'] = ceil($output['totals']['total'] / $output['perpage']);
    }
    if (isset($_GET['page']) && intval($_GET['page']) > 0 && intval($_GET['page']) <= $output['pages']) {
        $page = $_GET['page'];
    } else {
        $page = 1;
    }
    $output['totals']['recordstart'] = (($page == 1) ? 0 : (($page - 1) * $output['perpage']));
    $output['totals']['recordend'] = ($output['totals']['recordstart'] + $output['perpage']) - 1;
    if ($output['totals']['recordend'] > ($output['totals']['total'] - 1)) {
        $output['totals']['recordend'] = $output['totals']['total'] - 1;
    }
    $photos = array();
    foreach ($output['photos'] as $index => $photo) {
        if ($index >= $output['totals']['recordstart'] && $index <= $output['totals']['recordend']) {
            $photos[] = $photo;
        }
    }
    unset($output['photos']);
    $output['photos'] = $photos;
    
    ob_start("ob_gzhandler");
    echo json_encode($output);
    

    Hope someone finds this useful!

    Dan

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I want use html5's new tag to play a wav file (currently only supported
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.