本文整理汇总了PHP中phpFlickr::auth方法的典型用法代码示例。如果您正苦于以下问题:PHP phpFlickr::auth方法的具体用法?PHP phpFlickr::auth怎么用?PHP phpFlickr::auth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类phpFlickr
的用法示例。
在下文中一共展示了phpFlickr::auth方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: nextend_api_auth_flow
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>';
}
}
}
示例2: unset
/* 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);
}
示例3: phpFlickr
<?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>";
}
示例4: phpFlickr
<?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";
$f = new phpFlickr("c83eeb4b463c1203048589e3e24a5248", "e269f7cd32e05f50");
//change this to the permissions you will need
$f->auth("read");
echo "Copy this token into your code: " . $_SESSION['phpFlickr_auth_token'];
示例5: redirect
$_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&action=login');
break;
// call flickr login procedure
// call flickr login procedure
case 'login':
$flickr->auth('read', false);
break;
// message after login
// message after login
case 'logged':
$_SESSION['page_infos'][] = l10n('Successfully logged in to you Flickr account');
redirect(FLICKR_ADMIN . '-import');
break;
// logout
// logout
case 'logout':
unset($_SESSION['phpFlickr_auth_token']);
$_SESSION['page_infos'][] = l10n('Logged out');
redirect(FLICKR_ADMIN . '-import');
break;
// main menu
示例6: fjgwpp_createGallery
function fjgwpp_createGallery($action, $atts)
{
global $fjgwpp_imagesHeight_default;
global $fjgwpp_maxPhotosPP_default;
global $fjgwpp_lastRow_default;
global $fjgwpp_fixedHeight_default;
global $fjgwpp_pagination_default;
global $fjgwpp_lightbox_default;
global $fjgwpp_captions_default;
global $fjgwpp_showDescriptions_default;
global $fjgwpp_randomize_default;
global $fjgwpp_margins_default;
global $fjgwpp_openOriginals_default;
global $fjgwpp_bcontextmenu_default;
global $fjgwpp_flickrAPIWrapperVersion_default;
static $shortcode_unique_id = 0;
$ris = "";
$page_num = get_query_var('page') ? get_query_var('page') : 1;
$flickrGalID = 'flickrGal' . $shortcode_unique_id;
//Options-----------------------
extract(shortcode_atts(array('user_id' => fjgwpp_getOption('userID'), 'id' => NULL, 'tags' => NULL, 'tags_mode' => 'any', 'images_height' => fjgwpp_getOption('imagesHeight', $fjgwpp_imagesHeight_default), 'max_num_photos' => fjgwpp_getOption('maxPhotosPP', $fjgwpp_maxPhotosPP_default), 'last_row' => fjgwpp_getOption('lastRow', $fjgwpp_lastRow_default), 'fixed_height' => fjgwpp_getOption('fixedHeight', $fjgwpp_fixedHeight_default) == 1, 'lightbox' => fjgwpp_getOption('lightbox', $fjgwpp_lightbox_default), 'captions' => fjgwpp_getOption('captions', $fjgwpp_captions_default) == 1, 'show_descriptions' => fjgwpp_getOption('showDescriptions', $fjgwpp_showDescriptions_default) == 1, 'randomize' => fjgwpp_getOption('randomize', $fjgwpp_randomize_default) == 1, 'pagination' => fjgwpp_getOption('pagination', $fjgwpp_pagination_default), 'margins' => fjgwpp_getOption('margins', $fjgwpp_margins_default), 'open_originals' => fjgwpp_getOption('openOriginals', $fjgwpp_openOriginals_default) == 1, 'block_contextmenu' => fjgwpp_getOption('bcontextmenu', $fjgwpp_bcontextmenu_default) == 1, 'flickrAPIWrapperVersion' => fjgwpp_getOption('flickrAPIWrapperVersion', $fjgwpp_flickrAPIWrapperVersion_default) == 0), $atts));
//Trim string options
$user_id = trim($user_id);
$id = trim($id);
$lightbox = trim($lightbox);
$last_row = trim($last_row);
if ($flickrAPIWrapperVersion == 0) {
require_once "phpFlickr/phpFlickr.php";
} else {
require_once "phpFlickr_a" . $flickrAPIWrapperVersion . "/phpFlickr.php";
}
//LEGACY for the old options
if ($pagination === '1') {
$pagination = 'prevnext';
} else {
if ($pagination !== 'none' && $pagination !== 'prevnext' && $pagination !== 'numbers') {
$pagination = 'none';
}
}
if ($lightbox === '1') {
$lightbox = 'colorbox';
}
if ($lightbox === '0') {
$lightbox = 'none';
}
$images_height = (int) $images_height;
if ($images_height < 30) {
$images_height = 30;
}
$max_num_photos = (int) $max_num_photos;
if ($max_num_photos < 1) {
$max_num_photos = 1;
}
$margins = (int) $margins;
if ($margins < 0) {
$margins = 1;
}
if ($margins > 30) {
$margins = 30;
}
if ($pagination === 'none') {
$page_num = 1;
}
//-----------------------------
//Inizialization---------------
$flickrAPIKey = trim(fjgwpp_getOption('APIKey'));
//Flickr API Key
$flickrAPISecret = trim(fjgwpp_getOption('APISecret'));
//Flickr API Secret
$flickrAPIToken = trim(fjgwpp_getOption('APIToken'));
//Flickr API Token
if ($flickrAPISecret && $flickrAPIToken) {
// fully authenticated call
$f = new phpFlickr($flickrAPIKey, $flickrAPISecret);
$f->setToken($flickrAPIToken);
$f->auth("read");
} else {
// standard call
$f = new phpFlickr($flickrAPIKey);
}
$upload_dir = wp_upload_dir();
$f->enableCache("fs", $upload_dir['basedir'] . "/phpFlickrCache");
$photos_url = array();
$photos = array();
$photos_main_index = '';
$maximum_pages_nums = 10;
//TODO configurable?
//Errors-----------------------
if ($action === 'phs' || $action === 'gal' || $action === 'tag') {
if (!isset($user_id) || strlen($user_id) == 0) {
return fjgwpp_formatError(__('You must specify the user_id for this action, using the "user_id" attribute', 'fjgwpp'));
}
}
if ($action === 'gal') {
if (!isset($id) || strlen($id) == 0) {
return fjgwpp_formatError(__('You must specify the id of the gallery, using the "id" attribute', 'fjgwpp'));
}
}
if ($action === 'set') {
if (!isset($id) || strlen($id) == 0) {
//.........这里部分代码省略.........
示例7: auth
/**
* Authenticate onto Flickr unless already done. This redirects the user to the Flickr
* authentication page asking them to confirm access.
*
* @param string $permissions Specify 'read' or 'write' to determine the level of permissions required.
*/
public static function auth($permissions)
{
$f = new phpFlickr(parent::$flickr_api_key, parent::$flickr_api_secret);
$f->auth($permissions);
}
示例8: flickrsync_log_mesmo
function flickrsync_log_mesmo($msg)
{
error_log($msg . "\n", 3, "/tmp/flickrsync.err");
}
function flickrsync_vardump($var)
{
ob_start();
var_dump($var);
flickrsync_log_mesmo(ob_get_clean());
}
flickrsync_log('iniciando');
$f = new phpFlickr(FLICKR_API_KEY, FLICKR_API_SECRET);
flickrsync_log('instanciado');
$f->setToken(FLICKR_API_AUTH_TOKEN);
flickrsync_log('setado token');
$f->auth();
flickrsync_log('autenticado');
//change this to the permissions you will need
// $f->auth("read");
//echo "Copy this token into your code: " . $_SESSION['phpFlickr_auth_token'];
echo 'listanddo flickr';
//Parameterless searches have been disabled. Please use flickr.photos.getRecent instead.
$photos = $f->photos_search(array('user_id' => FLICKR_USER_ID));
//$photos = $this->phpFlickr->photos_getRecent();
if (false === $photos) {
print_r($f->getErrorCode());
echo "\n";
print_r($f->getErrorMsg());
echo "\n";
}
var_dump($photos);
示例9: fjgwpp_settings
function fjgwpp_settings()
{
global $fjgwpp_imagesHeight_default;
global $fjgwpp_maxPhotosPP_default;
global $fjgwpp_lastRow_default;
global $fjgwpp_fixedHeight_default;
global $fjgwpp_pagination_default;
global $fjgwpp_lightbox_default;
global $fjgwpp_provideColorbox_default;
global $fjgwpp_provideSwipebox_default;
global $fjgwpp_captions_default;
global $fjgwpp_showDescriptions_default;
global $fjgwpp_randomize_default;
global $fjgwpp_margins_default;
global $fjgwpp_openOriginals_default;
global $fjgwpp_bcontextmenu_default;
global $fjgwpp_flickrAPIWrapperVersion_default;
//Get Values
$fjgwpp_userID_saved = fjgwpp_getOption('userID', '');
$fjgwpp_APIKey_saved = fjgwpp_getOption('APIKey', '');
$fjgwpp_APISecret_saved = fjgwpp_getOption('APISecret', '');
$fjgwpp_APIToken_saved = fjgwpp_getOption('APIToken', '');
$fjgwpp_imagesHeight_saved = (int) fjgwpp_getOption('imagesHeight', $fjgwpp_imagesHeight_default);
$fjgwpp_maxPhotosPP_saved = (int) fjgwpp_getOption('maxPhotosPP', $fjgwpp_maxPhotosPP_default);
$fjgwpp_lastRow_saved = (int) fjgwpp_getOption('lastRow', $fjgwpp_lastRow_default);
$fjgwpp_fixedHeight_saved = (int) fjgwpp_getOption('fixedHeight', $fjgwpp_fixedHeight_default);
$fjgwpp_pagination_saved = fjgwpp_getOption('pagination', $fjgwpp_pagination_default);
$fjgwpp_lightbox_saved = fjgwpp_getOption('lightbox', $fjgwpp_lightbox_default);
$fjgwpp_provideColorbox_saved = (int) fjgwpp_getOption('provideColorbox', $fjgwpp_provideColorbox_default);
$fjgwpp_provideSwipebox_saved = (int) fjgwpp_getOption('provideSwipebox', $fjgwpp_provideSwipebox_default);
$fjgwpp_captions_saved = (int) fjgwpp_getOption('captions', $fjgwpp_captions_default);
$fjgwpp_showDescriptions_saved = (int) fjgwpp_getOption('showDescriptions', $fjgwpp_showDescriptions_default);
$fjgwpp_randomize_saved = (int) fjgwpp_getOption('randomize', $fjgwpp_randomize_default);
$fjgwpp_margins_saved = (int) fjgwpp_getOption('margins', $fjgwpp_margins_default);
$fjgwpp_openOriginals_saved = (int) fjgwpp_getOption('openOriginals', $fjgwpp_openOriginals_default);
$fjgwpp_bcontextmenu_saved = (int) fjgwpp_getOption('bcontextmenu', $fjgwpp_bcontextmenu_default);
$fjgwpp_flickrAPIWrapperVersion_saved = (int) fjgwpp_getOption('flickrAPIWrapperVersion', $fjgwpp_flickrAPIWrapperVersion_default);
//Save Values
if (isset($_POST['Submit'])) {
$error = false;
$error_msg = "";
$fjgwpp_flickrAPIWrapperVersion_saved = (int) $_POST["fjgwpp_flickrAPIWrapperVersion"];
if ($fjgwpp_flickrAPIWrapperVersion_saved == 0) {
require_once "phpFlickr/phpFlickr.php";
} else {
require_once "phpFlickr_a" . $fjgwpp_flickrAPIWrapperVersion_saved . "/phpFlickr.php";
}
//Check the API Key
$fjgwpp_APIKey_saved = trim(htmlentities($_POST["fjgwpp_APIKey"], ENT_QUOTES));
//Check the API Secret
$fjgwpp_APISecret_saved = trim(htmlentities($_POST["fjgwpp_APISecret"], ENT_QUOTES));
//Check the API Token
$fjgwpp_APIToken_saved = trim(htmlentities($_POST["fjgwpp_APIToken"], ENT_QUOTES));
if ($fjgwpp_APISecret_saved && $fjgwpp_APIToken_saved) {
// test fully authenticated call
$f = new phpFlickr($fjgwpp_APIKey_saved, $fjgwpp_APISecret_saved);
$f->setToken($fjgwpp_APIToken_saved);
$f->auth("read");
if ($f->test_echo() == false) {
$error = true;
$error_msg .= '<li>' . __('API Secret or Token are not valid', 'fjgwpp') . '</li>';
}
} else {
// test standard call
$f = new phpFlickr($fjgwpp_APIKey_saved);
if ($f->test_echo() == false) {
$error = true;
$error_msg .= '<li>' . __('API Key is not valid', 'fjgwpp') . '</li>';
}
}
$fjgwpp_userID_saved = trim(htmlentities($_POST["fjgwpp_userID"], ENT_QUOTES));
if (!$error) {
if ($f->urls_getUserProfile($fjgwpp_userID_saved) == false) {
$error = true;
$error_msg .= '<li>' . __('Invalid UserID', 'fjgwpp') . '</li>';
}
}
$fjgwpp_imagesHeight_saved = (int) $_POST["fjgwpp_imagesHeight"];
if ($fjgwpp_imagesHeight_saved < 30) {
$error = true;
$error_msg .= '<li>' . __('The \'Images Height\' field must have a value greater than or equal to 30', 'fjgwpp') . '</li>';
}
$fjgwpp_maxPhotosPP_saved = (int) $_POST["fjgwpp_maxPhotosPP"];
if ($fjgwpp_maxPhotosPP_saved <= 0) {
$error = true;
$error_msg .= '<li>' . __('The \'Photos per page\' field must have a value greater than 0', 'fjgwpp') . '</li>';
}
$fjgwpp_lastRow_saved = htmlentities($_POST["fjgwpp_lastRow"], ENT_QUOTES);
if (isset($_POST["fjgwpp_fixedHeight"])) {
$fjgwpp_fixedHeight_saved = (int) $_POST["fjgwpp_fixedHeight"] != 0 ? 1 : 0;
} else {
$fjgwpp_fixedHeight_saved = 0;
}
$fjgwpp_pagination_saved = htmlentities($_POST["fjgwpp_pagination"], ENT_QUOTES);
$fjgwpp_lightbox_saved = htmlentities($_POST["fjgwpp_lightbox"], ENT_QUOTES);
if (isset($_POST["fjgwpp_provideColorbox"])) {
$fjgwpp_provideColorbox_saved = (int) $_POST["fjgwpp_provideColorbox"] != 0 ? 1 : 0;
} else {
$fjgwpp_provideColorbox_saved = 0;
}
//.........这里部分代码省略.........