Esempio n. 1
0
function nextend_api_auth_flow()
{
    $api_key = NextendRequest::getVar('api_key');
    $api_secret = NextendRequest::getVar('api_secret');
    if (session_id() == "") {
        @session_start();
    }
    if (!$api_key || !$api_secret) {
        $api_key = isset($_SESSION['api_key']) ? $_SESSION['api_key'] : null;
        $api_secret = isset($_SESSION['api_secret']) ? $_SESSION['api_secret'] : null;
    } else {
        $_SESSION['api_key'] = $api_key;
        $_SESSION['api_secret'] = $api_secret;
    }
    if ($api_key && $api_secret) {
        require_once dirname(__FILE__) . "/api/phpFlickr.php";
        $f = new phpFlickr($api_key, $api_secret);
        if (empty($_GET['frob'])) {
            $f->auth('read', false);
        } else {
            $result = $f->auth_getToken($_GET['frob']);
            unset($_SESSION['api_key']);
            unset($_SESSION['api_secret']);
            unset($_SESSION['phpFlickr_auth_token']);
            echo '<script type="text/javascript">';
            echo 'window.opener.setToken("' . $result['token'] . '");';
            echo '</script>';
        }
    }
}
Esempio n. 2
0
/* Last updated with phpFlickr 2.3.2
 *
 * Edit these variables to reflect the values you need. $default_redirect 
 * and $permissions are only important if you are linking here instead of
 * using phpFlickr::auth() from another page or if you set the remember_uri
 * argument to false.
 */
$api_key = "[your api key]";
$api_secret = "[your api secret]";
$default_redirect = "/";
$permissions = "read";
$path_to_phpFlickr_class = "./";
ob_start();
require_once $path_to_phpFlickr_class . "phpFlickr.php";
unset($_SESSION['phpFlickr_auth_token']);
if (isset($_SESSION['phpFlickr_auth_redirect']) && !empty($_SESSION['phpFlickr_auth_redirect'])) {
    $redirect = $_SESSION['phpFlickr_auth_redirect'];
    unset($_SESSION['phpFlickr_auth_redirect']);
}
$f = new phpFlickr($api_key, $api_secret);
if (empty($_GET['frob'])) {
    $f->auth($permissions, false);
} else {
    $f->auth_getToken($_GET['frob']);
}
if (empty($redirect)) {
    header("Location: " . $default_redirect);
} else {
    header("Location: " . $redirect);
}
Esempio n. 3
0
    if (!test_remote_download()) {
        $page['errors'][] = l10n('No download method available');
        $_GET['action'] = 'error';
    } else {
        // init flickr API
        include_once FLICKR_PATH . 'include/phpFlickr/phpFlickr.php';
        $flickr = new phpFlickr($conf['flickr2piwigo']['api_key'], $conf['flickr2piwigo']['secret_key']);
        $flickr->enableCache('fs', FLICKR_FS_CACHE);
        // must authenticate
        $u = $flickr->test_login();
        if (($u === false or empty($_SESSION['phpFlickr_auth_token'])) and @$_GET['action'] != 'login') {
            $_GET['action'] = 'init_login';
        }
        // generate token after authentication
        if (!empty($_GET['frob'])) {
            $flickr->auth_getToken($_GET['frob']);
            $_GET['action'] = 'logged';
        }
    }
}
if (!isset($_GET['action'])) {
    $_GET['action'] = 'main';
}
switch ($_GET['action']) {
    // button to login page
    case 'init_login':
        $template->assign('flickr_login', FLICKR_ADMIN . '-import&amp;action=login');
        break;
        // call flickr login procedure
    // call flickr login procedure
    case 'login':
Esempio n. 4
0
<?php

/* Last updated with phpFlickr 1.4
 *
 * If you need your app to always login with the same user (to see your private
 * photos or photosets, for example), you can use this file to login and get a
 * token assigned so that you can hard code the token to be used.  To use this
 * use the phpFlickr::setToken() function whenever you create an instance of 
 * the class.
 */
require_once "phpFlickr.php";
$apiKey = "5f1ba3cb88d4ed7b109be31f9fb928a4";
$secret = "13ce4def3dfd80d5";
$perms = "delete";
$f = new phpFlickr($apiKey, $secret);
//Redirect to flickr for authorization
if (!$_GET['frob']) {
    $f->auth($perms);
} else {
    //If authorized, print the token
    $tokenArgs = $f->auth_getToken($_GET['frob']);
    echo "<pre>";
    var_dump($tokenArgs);
    echo "</pre>";
}
Esempio n. 5
0
$f = new phpFlickr($key, $secret);
$read_directory = "/tmp/Snapshots/";
$write_directory = "/tmp/Snapshots_Bak/";
$title = "FlickrSync";
$desc = "FlickrSync";
$tags = "flickrsync";
if (empty($frob)) {
    $frob = $f->auth_getFrob();
    $api_sig = md5($secret . "api_key" . $key . "frob" . $frob . "permswrite");
    $auth_url = "http://flickr.com/services/auth/?api_key={$key}&perms=write&frob={$frob}&api_sig={$api_sig}";
    echo "TWO STEPS YOU MUST NOW TAKE:\n\n";
    echo "1. SET THE frob VARIABLE TO: {$frob}\n\n";
    echo "2. VISIT {$auth_url} AND APPROVE THE APPLICATION!\n\n";
    echo "RERUN WHEN YOU HAVE SET FROB\n\n";
} elseif (empty($token)) {
    $token = $f->auth_getToken($frob);
    echo "PLEASE SET THE TOKEN VALUE TO THE TOKEN MENTIONED BELOW, SAVE, AND RERUN THE APPLICATION:";
    echo print_r($token) . "\n\n\n";
} else {
    $f->setToken($token);
    echo "ENTERING MASTER LOOP\n";
    while (1) {
        echo "I'm awake!!!\n";
        $filenames_to_upload = array();
        if ($handle = opendir($read_directory)) {
            while (($file = readdir($handle)) !== false) {
                echo "NEW FILE: {$file} \n\n";
                array_push($filenames_to_upload, $file);
            }
            closedir($handle);
        }