예제 #1
0
<?php

$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;
$flickr = new Flickr($flickrApiKey, $flickrApiSecret);
$token = $_POST['token'];
if (!empty($token)) {
    $flickr->convertOldToken($token);
}
?>
<!DOCTYPE html>
<html>
    <head>
        <title>DPZFlickr Convert Token Example</title>
        <link rel="stylesheet" href="example.css" />
    </head>
    <body>
        <h1>Convert Token</h1>

        <form action="<?php 
echo $_SERVER['SCRIPT_NAME'];
?>
예제 #2
0
파일: index.php 프로젝트: AfzalH/DPZFlickr
<?php

$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;
$flickr = new Flickr($flickrApiKey, $flickrApiSecret);
$parameters = array('user_id' => '50317659@N00', 'per_page' => 100, 'extras' => 'url_sq,path_alias');
$response = $flickr->call('flickr.photos.search', $parameters);
$photos = $response['photos'];
?>
<!DOCTYPE html>
<html>
    <head>
        <title>DPZFlickr Example</title>
        <link rel="stylesheet" href="example.css" />
    </head>
    <body>
        <h1>Photos from dopiaza</h1>
        <ul id="photos">
            <?php 
foreach ($photos['photo'] as $photo) {
    ?>
                <li>
예제 #3
0
<?php

$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;
$flickr = new Flickr($flickrApiKey, $flickrApiSecret);
$flickr->signout();
?>
<!DOCTYPE html>
<html>
    <head>
        <title>DPZFlickr Auth Signout Example</title>
        <link rel="stylesheet" href="example.css" />
    </head>
    <body>
        <h1>Signed out</h1>
        <p>You have now signed out of this Flickr session. <a href="auth.php">Sign in</a>.</p>
        <p><a href="index.php">Unauthenticated Example</a> |
            <a href="auth.php">Authenticated Example</a> |
            <a href="convert-token.php">Convert Token Example</a> <br/>
            <a href="upload.php">Upload Photo Example</a> |
            <a href="replace.php">Replace Photo Example</a>
        </p>
 function getPhotosInPhotoset($id)
 {
     $yaml_path = $_SERVER['DOCUMENT_ROOT'] . '/_content/photos/';
     $flickr = new Flickr(self::api_key, self::api_secret);
     $parameters = array('photoset_id' => $id, 'extras' => 'description,url_o,url_l,url_m,url_s,geo,date_taken,tags,owner_name');
     $response = $flickr->call('flickr.photosets.getPhotos', $parameters);
     foreach ($response['photoset']['photo'] as $photo) {
         //first of all check if we already have this image on home server...
         $slug = Slug::make($photo['id']);
         $slug = preg_replace('/[^a-z\\d]+/i', '-', $slug);
         $datetime = date('Y-m-d-Hi', strtotime($photo['datetaken']));
         $file = $datetime . "-" . $slug . ".md";
         $archive_file = preg_replace('"\\.md$"', '.gallery', $file);
         $collection_file = preg_replace('"\\.md$"', '.collection', $file);
         if (!File::exists($yaml_path . $file) && !File::exists($yaml_path . $archive_file) && !File::exists($yaml_path . $collection_file)) {
             $this->log->info('Trying to create a gallery without a pre-exiting photo `' . $photo['title'] . '`');
             return false;
         } else {
             //archive this file, it slows down the site.
             if (File::exists($yaml_path . $file)) {
                 rename($yaml_path . $file, $yaml_path . $archive_file);
             }
             if (File::exists($yaml_path . $collection_file)) {
                 rename($yaml_path . $collection_file, $yaml_path . $archive_file);
             }
             //we're fine to start writing the array
             $arr_return[] = $this->makePhotoYAML($photo);
         }
     }
     return $arr_return;
 }
예제 #5
0
파일: auth.php 프로젝트: AfzalH/DPZFlickr
<?php

$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']);
}
예제 #6
0
파일: upload.php 프로젝트: AfzalH/DPZFlickr
<?php

$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'];
예제 #7
0
<?php

$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)) {
    $photoId = @$_POST['photoid'];
    $parameters = array('photo_id' => $photoId);
    $photo = $_FILES['photo'];
    if ($photo['size'] > 0) {
        $parameters['photo'] = '@' . $photo['tmp_name'];
    }
    $response = $flickr->replace($parameters);
    $ok = @$response['stat'];
    if ($ok == 'ok') {
        $photos = $response['photos'];