Example #1
0
$configFile = dirname(__FILE__) . '/config.php';
if (file_exists($configFile)) {
    include $configFile;
} else {
    die("Please rename the config-sample.php file to config.php and add your Flickr API key and secret to it\n");
}
spl_autoload_register(function ($className) {
    $className = str_replace('\\', DIRECTORY_SEPARATOR, $className);
    include dirname(__FILE__) . '/../src/' . $className . '.php';
});
use DPZ\Flickr;
// Build the URL for the current page and use it for our callback
$callback = sprintf('%s://%s:%d%s', @$_SERVER['HTTPS'] == "on" ? 'https' : 'http', $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['SCRIPT_NAME']);
$flickr = new Flickr($flickrApiKey, $flickrApiSecret, $callback);
if (!$flickr->authenticate('read')) {
    die("Hmm, something went wrong...\n");
}
$userNsid = $flickr->getOauthData(Flickr::USER_NSID);
$userName = $flickr->getOauthData(Flickr::USER_NAME);
$userFullName = $flickr->getOauthData(Flickr::USER_FULL_NAME);
$parameters = array('per_page' => 100, 'extras' => 'url_sq,path_alias');
$response = $flickr->call('flickr.stats.getPopularPhotos', $parameters);
$ok = @$response['stat'];
if ($ok == 'ok') {
    $photos = $response['photos'];
} else {
    $err = @$response['err'];
    die("Error: " . @$err['msg']);
}
?>
Example #2
0
$configFile = dirname(__FILE__) . '/config.php';
if (file_exists($configFile)) {
    include $configFile;
} else {
    die("Please rename the config-sample.php file to config.php and add your Flickr API key and secret to it\n");
}
spl_autoload_register(function ($className) {
    $className = str_replace('\\', DIRECTORY_SEPARATOR, $className);
    include dirname(__FILE__) . '/../src/' . $className . '.php';
});
use DPZ\Flickr;
// Build the URL for the current page and use it for our callback
$callback = sprintf('%s://%s:%d%s', @$_SERVER['HTTPS'] == "on" ? 'https' : 'http', $_SERVER['SERVER_NAME'], $_SERVER['SERVER_PORT'], $_SERVER['SCRIPT_NAME']);
$flickr = new Flickr($flickrApiKey, $flickrApiSecret, $callback);
if (!$flickr->authenticate('write')) {
    die("Hmm, something went wrong...\n");
}
$message = "";
if (!empty($_POST)) {
    $title = @$_POST['title'];
    $parameters = array('title' => $title, 'tags' => 'DPZFlickr');
    $photo = $_FILES['photo'];
    if ($photo['size'] > 0) {
        $parameters['photo'] = '@' . $photo['tmp_name'];
    }
    $response = $flickr->upload($parameters);
    $ok = @$response['stat'];
    if ($ok == 'ok') {
        $photos = $response['photos'];
        $message = "Photo uploaded";