| Flickr::API(3pm) | User Contributed Perl Documentation | Flickr::API(3pm) |
Flickr::API - Perl interface to the Flickr API
use Flickr::API;
my $api = Flickr::API->new({
'consumer_key' => 'your_api_key',
'consumer_secret' => 'your_app_secret',
});
my $response = $api->execute_method('flickr.test.echo', {
'foo' => 'bar',
'baz' => 'quux',
});
my $config_file = $HOME/saved-flickr.st;
$api->export_storable_config($config_file);
use Flickr::API;
# key deprecated in favor of api_key
# secret deprecated in favor of api_secret
#
my $api = Flickr::API->new({
'api_key' => 'your_api_key',
'api_secret' => 'your_app_secret',
});
my $response = $api->execute_method('flickr.test.echo', {
'foo' => 'bar',
'baz' => 'quux',
});
use Flickr::API;
use Flickr::API::Request;
my $api = Flickr::API->new({'consumer_key' => 'your_api_key','consumer_secret' => 'your_app_secret'});
my $request = Flickr::API::Request->new({
'method' => 'flickr.test.echo',
'args' => {},
});
my $response = $api->execute_request($request);
use Flickr::API;
use Term::ReadLine;
my $config_file = "$ENV{HOME}/saved-flickr.st";
my $term = Term::ReadLine->new('Testing Flickr::API');
$term->ornaments(0);
my $api = Flickr::API->import_storable_config($config_file);
my $rt_rc = $api->oauth_request_token( { 'callback' => 'https://127.0.0.1/' } );
my %request_token;
if ( $rt_rc eq 'ok' ) {
my $uri = $api->oauth_authorize_uri({ 'perms' => 'read' });
my $prompt = "\n\n$uri\n\n" .
"Copy the above url to a browser, and authenticate with Flickr\n" .
"Press [ENTER] once you get the redirect: ";
my $input = $term->readline($prompt);
$prompt = "\n\nCopy the redirect URL from your browser and enter it\nHere: ";
$input = $term->readline($prompt);
chomp($input);
my ($callback_returned,$token_received) = split(/\?/,$input);
my (@parms) = split(/\&/,$token_received);
foreach my $pair (@parms) {
my ($key,$val) = split(/=/,$pair);
$key =~ s/oauth_//;
$request_token{$key}=$val;
}
}
my $ac_rc = $api->oauth_access_token(\%request_token);
if ( $ac_rc eq 'ok' ) {
$api->export_storable_config($config_file);
my $response = $api->execute_method('flickr.auth.oauth.checkToken');
my $hash_ref = $response->as_hash();
$response = $api->execute_method('flickr.prefs.getPrivacy');
my $rsp_node = $response->as_tree();
}
https://api.flickr.com/services/oauth/authorize?oauth_token=12345678901234567-890abcdefedcba98&perms=read
https://127.0.0.1/?oauth_token=12345678901234567-890abcdefedcba98&oauth_verifier=cafe12345678feed
An interface for using the Flickr API.
"Flickr::API" is a subclass of LWP::UserAgent, so all of the various proxy, request limits, caching, etc are available. "Flickr::API" can instantiate using either the Flickr Authentication (deprecated) or the OAuth Authentication. OAuth is handled using Net::OAuth.
$perms must be read, write, or delete.
For web-based applications $frob is an optional parameter.
Returns undef if a secret was not specified when creating the "Flickr::API" object.
If the Flickr::API object identifies as Flickr original authentication, return a hashref
$VAR1 = {
'frob' => '12332112332112300-feedabcde123456c-1234567',
'api_key' => 'cafefeedbeef13579246801234567890',
'api_secret' => 'beef321432154321',
'token' => '97531086421234567-cafe123456789abc'
};
or the subset thereof depending on what has been used by the API. If the older form of key/secret was used, the constructor will change these to the api_key/api_secret forms.
If the API object identifies as OAuth authentication, and "message type" is specified, then export_config will return a hash of the OAuth parameters for the specified Net::OAuth message type. Further, if parameter is specified, then export_config returns either either the set of message parameters or api parameters for the message type. If parameter is not specified then both parameter type are returned. For example:
my %config = $api->export_config('protected resource');
or
my %config = $api->export_config('protected resource','message');
When export_config is called without arguments, then it returns the OAuth portion of the Flickr::API object. If present the Net::OAuth Request Token and Access Token objects are also included.
VAR1 = {
'access_token' => bless( {
'extra_params' => {
'fullname' => 'Louis',
'user_nsid' => '12345678@N00',
'username' => 'meanameicallmyself'
},
'from_hash' => 1,
'token' => '12345678901234567-cafe123098765432',
'token_secret' => 'eebeef000fedbca1'
}, 'Net::OAuth::AccessTokenResponse' ),
'callback' => 'https://127.0.0.1',
'consumer_key' => 'cafefeedbeef13579246801234567890',
'consumer_secret' => 'fedcba9876543210',
'nonce' => '917fa882fa7babd5a1b7702e7d19502a',
'request_method' => 'GET',
'request_url' => 'https://api.flickr.com/services/rest/',
'signature_method' => 'HMAC-SHA1',
'timestamp' => 1436129308,
'token' => '12345678901234567-cafe123098765432',
'token_secret' => 'eebeef000fedbca1',
'version' => '1.0'
};
my %config = $api->export_config();
This method can be used to extract and save the API parameters for future use.
The required parameters are:
The required parameters are:
Cal Henderson, <cal@iamcal.com>
Auth API patches provided by Aaron Straup Cope
Subclassing patch from AHP
OAuth patches and additions Louis B. Moore <lbmoore@cpan.org>
Copyright (C) 2004-2013, Cal Henderson, <cal@iamcal.com>
OAuth patches and additions Copyright (C) 2014-2016 Louis B. Moore <lbmoore@cpan.org>
This program is released under the Artistic License 2.0 by The Perl Foundation.
Flickr::API::Request, Flickr::API::Response, Net::OAuth, XML::Parser::Lite, Flickr <http://www.flickr.com/>, <http://www.flickr.com/services/api/> <https://www.flickr.com/services/api/auth.oauth.html> <https://github.com/iamcal/perl-Flickr-API>
| 2024-03-02 | perl v5.38.2 |