NAME
Flickr::API - Perl interface to the Flickr API
SYNOPSIS
Using OAuth authentication
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',
});
Using Original Flickr authentication
use Flickr::API;
my $api = Flickr::API->new({
'key' => 'your_api_key',
'secret' => 'your_app_secret',
});
my $response = $api->execute_method('flickr.test.echo', {
'foo' => 'bar',
'baz' => 'quux',
});
Alternatively, Using OAuth authentication
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);
Alternatively, Using Original Flickr authentication
use Flickr::API;
use Flickr::API::Request;
my $api = Flickr::API->new({'key' => 'your_api_key'});
my $request = Flickr::API::Request->new({
'method' => 'flickr.test.echo',
'args' => {},
});
my $response = $api->execute_request($request);
DESCRIPTION
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.
METHODS
new({ opt => 'value', ... })
-
Returns as new Flickr::API object. The options are as follows:
- either
key
for the Flickr auth orconsumer_key
for OAuth -
Your API key (one or the other form is required)
- either
secret
for the Flickr auth orconsumer_secret
for OAuth -
Your API key's secret (the one matching the key/consumer_key is required)
rest_uri
&auth_uri
-
Override the URIs used for contacting the API.
lwpobj
-
Base the
Flickr::API
on this object, instead of creating a new instance of LWP::UserAgent. This is useful for using the features of e.g. LWP::UserAgent::Cached. unicode
-
This flag controls whether Flickr::API expects you to pass UTF-8 bytes (unicode=0, the default) or actual unicode strings (unicode=1) in the request.
nonce
,timestamp
,request_method
,signature_method
,request_url
-
These values are used by Net::OAuth to assemble and sign OAuth consumer request Flickr API calls. The defaults are usually fine.
callback
-
The callback is used in oauth authentication. When Flickr authorizes you, it returns the access token and access token secret in a callback URL. This defaults to https://127.0.0.1/
token
andtoken_secret
-
These values are used by Net::OAuth to assemble and sign OAuth protected resource request Flickr API calls.
- either
execute_method($method, $args)
-
Constructs a Flickr::API::Request object and executes it, returning a Flickr::API::Response object.
execute_request($request)
-
Executes a Flickr::API::Request object, returning a Flickr::API::Response object. Calls are signed if a secret was specified when creating the Flickr::API object.
request_auth_url($perms,$frob)
-
Returns a URI object representing the URL that an application must redirect a user to for approving an authentication token.
For web-based applications $frob is an optional parameter.
Returns undef if a secret was not specified when creating the
Flickr::API
object. oauth_export_config([$type,$params])
-
Returns a hash of all or part of the OAuth portion of the Flickr::API object
- oauth message type: one of
Consumer
,Protected Resource
,Request Token
,Authorize User
orAccess Token
-
This is one of the the message type that Net::OAuth handles. Message type is optional.
- oauth parameter set:
message
orAPI
or undef. -
Net::OAuth will return message params, api params or all params depending on what is requested. All params is the default.
If
message type
is specified oauth_export_config will return a hash of the OAuth parameters for the specified type. Further, if parameter is specified, then oauth_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->oauth_export_config('protected resource');
or
my %config = $api->oauth_export_config('protected resource','message');
When oauth_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.
my %config = $api->oauth_export_config();
This method can be used to extract and save the OAuth parameters for future use.
- oauth message type: one of
oauth_export_storable_config(filename)
-
This method wraps oauth_export_config with a file open and storable store_fd to add some persistence to an oauth flavored Flickr::API object.
oauth_import_storable_config(filename)
-
This method retrieves a storable oauth config of a Flickr::API object and revivifies the object.
get_oauth_request_type()
-
Returns the oauth request type in the Flickr::API object. Some Flickr methods will require a
protected resource
request type and others a simpleconsumer
request type. oauth_request_token(\%args)
-
Assembles, signs, and makes the OAuth Request Token call, and if sucessful stores the Net::OAuth Request Token in the Flickr::API object.
The required paramters are:
consumer_key
-
Your API Key
consumer_secret
-
Your API Key's secret
request_method
-
The URI Method: GET or POST
request_url
-
Defaults to: https://api.flickr.com/services/oauth/request_token
oauth_access_token(\%args)
-
Assembles, signs, and makes the OAuth Access Token call, and if sucessful stores the Net::OAuth Access Token in the Flickr::API object.
The required paramters are:
consumer_key
-
Your API Key
consumer_secret
-
Your API Key's secret
request_method
-
The URI Method: GET or POST
request_url
-
Defaults to: https://api.flickr.com/services/oauth/access_token
token_secret
-
The request token secret from the Net::OAuth Request Token object returned from the oauth_request_token call.
-
Returns a URI object representing the URL that an application must redirect a user to for approving a request token.
perms
-
Permission the application is requesting, defaults to read.
is_oauth
-
Returns 1 if the Flickr::API object is OAuth flavored, 0 otherwise.
AUTHOR
Copyright (C) 2004-2013, Cal Henderson, <cal@iamcal.com>
Auth API patches provided by Aaron Straup Cope
Subclassing patch from AHP
OAuth patches and additions Copyright (C) 2014-2015 Louis B. Moore <lbmoore@cpan.org> License: Perl Artistic License 2.0
LICENSE
This program is released under the Artistic License 2.0 by The Perl Foundation.
SEE ALSO
Flickr::API::Request, Flickr::API::Response, Net::OAuth, XML::Parser::Lite, 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