Beispiel #1
0
function display_mini($photoid)
{
    $api = Phlickr_Api::createFrom(API_CONFIG_FILE);
    $p = new Phlickr_Photo($api, $photoid);
    $title = $p->getTitle();
    print '<small>' . $title . '</small><a href="' . $p->buildUrl() . '"><img src="' . $p->buildImgURL('t') . '" border="0" /></a>';
}
Beispiel #2
0
 function testCreateFrom_AllSettings()
 {
     $filename = tempnam('/tmp', 'foo');
     $settings = "api_key=key\n" . "api_secret=secret\n" . "api_token=token\n" . "cache_file=c:\filename\n";
     file_put_contents($filename, $settings);
     $api = Phlickr_Api::createFrom($filename);
     unlink($filename);
     $this->assertType('Phlickr_Api', $api);
     $this->assertEquals('key', $api->getKey(), 'key was not loaded correctly.');
     $this->assertEquals('secret', $api->getSecret(), 'secret was not loaded correctly.');
     $this->assertEquals('token', $api->getAuthToken(), 'token was not loaded correctly.');
     $this->assertEquals('c:\\filename', $api->getCacheFilename(), 'cache filename was not loaded correctly.');
 }
 * @version $Id$
 * @author  Andrew Morton <*****@*****.**>
 * @license http://opensource.org/licenses/lgpl-license.php
 *          GNU Lesser General Public License, Version 2.1
 */
// use the GetToken.php script to generate a config file.
define('API_CONFIG_FILE', dirname(__FILE__) . './authinfo.cfg');
// the cache file isn't required but if you share it's nice.
define('CACHE_FILE', dirname(__FILE__) . '/cache.tmp');
require_once 'Phlickr/Api.php';
require_once 'Phlickr/PhotoList.php';
require_once 'Phlickr/PhotoListIterator.php';
print "This script lets you select photos by tag and then set the taken date\n";
print "to a month-year date.\n\n";
// set up the api connection
$api = Phlickr_Api::createFrom(API_CONFIG_FILE);
$api->setCacheFilename(CACHE_FILE);
if (!$api->isAuthValid()) {
    die("invalid flickr logon");
}
// get a list of tags
print 'Enter a comma separated list of tags: ';
$tags = trim(fgets(STDIN));
// create a request to search for your photos with the tags.
$request = $api->createRequest('flickr.photos.search', array('tags' => $tags, 'tag_mode' => 'all', 'user_id' => $api->getUserId()));
// use the photo list to parse the search results
print "Searching for matching photos tagged with '{$tags}'...\n";
$pl = new Phlickr_PhotoList($request, Phlickr_PhotoList::PER_PAGE_MAX);
print "Found {$pl->getCount()} photos.\n";
print 'Year: ';
$year = (int) trim(fgets(STDIN));
Beispiel #4
0
function getApi()
{
    // set up the api connection
    $api = Phlickr_Api::createFrom(API_CONFIG_FILE);
    if (!$api->isAuthValid()) {
        die("invalid flickr logon");
    }
    return $api;
}