This sample demonstrates how to search for photos by tag, sort photos, and create a photoset.
<?php
include_once 'Phlickr/Api.php';
include_once 'Phlickr/AuthedPhotosetList.php';
include_once 'Phlickr/PhotoList.php';
include_once 'Phlickr/PhotoListIterator.php';
require_once 'Phlickr/PhotoSorter.php';
require_once 'Phlickr/PhotoSortStrategy/ByColor.php';
// use the GetToken.php script to generate a config file.
define('API_CONFIG_FILE', './authinfo.cfg');
// the cache file isn't required but if you share it's nice.
define('CACHE_FILE', dirname(__FILE__) . '/cache.tmp');
print('Comma separated list of tags: ');
// split the tags into an array, dropping commas and white space.
$tags = trim(fgets(STDIN));
// create a request to search for photos tagged with person and happy
// from all users.
$api = Phlickr_Api::createFrom(API_CONFIG_FILE);
$request = $api->createRequest(
'flickr.photos.search',
array(
'tags' => $tags,
'tag_mode' => 'all',
'user_id' => $api->getUserId()
)
);
// use the photo list and photo list iterator to display the titles and urls
// of each of the photos.
print "Searching for matching photos...\n";
$pl = new Phlickr_PhotoList($request, Phlickr_PhotoList::PER_PAGE_MAX);
$count = $pl->getCount();
if ($count == 0) {
print "No photos could be found tagged with $tags.\n";
} else {
print "Found $count photos tagged with $tags...\n";
// create a sorter that will uses the color sort strategy
$strategy = new Phlickr_PhotoSortStrategy_ByColor($api->getCache());
$sorter = new Phlickr_PhotoSorter($strategy);
// use a photolist iterator so that all the pages are sorted.
print "Sorting the photos (this might take a while)...\n";
$photos = $sorter->sort(new Phlickr_PhotoListIterator($pl));
$photo_ids = Phlickr_PhotoSorter::idsFromPhotos($photos);
// create the authed photoset list for the current user...
$apsl = new Phlickr_AuthedPhotosetList($api);
// .. and create a new photo set
$id = $apsl->create($tags, 'photo set created from tags ' . $tags, $photo_ids[0]);
// wait a few seconds for the set to be created
sleep(3);
// now, create the photset ojbect and add the photos
$aps = new Phlickr_AuthedPhotoset($api, $id);
$aps->editPhotos($photo_ids[0], $photo_ids);
print "Created a photoset named '$tags':\n". $aps->buildUrl() ."\n";
}
?>
Phototest
Hi friends, I have read many post from this blog and all of them were interested to read out, it's such a nice effort by the owner but I need some information about the 640-460 and 70-238 exam, but still unable to find the required information so it would be great for me if anyone could refer me some page with the required information especially about the 70-291 exam.