Authentication Token

Flickr uses a numeric value that they call an authentication token to link the permissions a user grants to an application. You’ll need to have an API key and secret.

To obtain an auth token, you can run the following script on a comand line:

#!/usr/local/bin/php -q
<?php
include_once 'Phlickr/Api.php';
 
// Prevent from enforcing a time limit on this script
//set_time_limit(-1);
ini_set('max_execution_time', 0);
 
print "This script will help you retrieve a Flickr authorization Token.\n\n";
 
// Get the user's API key and secret.
print 'API Key: ';
$api_key = trim(fgets(STDIN));
print 'API Secret: ';
$api_secret = trim(fgets(STDIN));
 
// Create an API object, then request a frob.
$api = new Phlickr_Api($api_key, $api_secret);
$frob = $api->requestFrob();
print "\nGot a frob: $frob\n";
 
// Find out the desired permissions.
print 'Permissions (read, write, or delete): ';
$perms = trim(fgets(STDIN));
 
// Build the authentication URL.
$url = $api->buildAuthUrl($perms, $frob);
print "\nOpen the following URL and authorize:\n$url\n";
print "\nPress return when you're finished...\n";
fgets(STDIN);
 
// After they've granted permission, conver the frob to a token.
$token = $api->setAuthTokenFromFrob($frob);
 
// Print out the token.
print "Auth token: $token\n";
?>

Code Text

 
auth_token.txt · Last modified: 2006/04/09 12:48 by drewish
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki