ImgurAPI perl library

ImgurAPI::Client is a perl5 client library for interfacing with Imgur's API endpoints.

Installation

  1. Clone the repository git clone https://github.com/selftaught/ImgurAPI.git
  2. Cd into the repo root and generate a makefile: perl Makefile.pl
  3. Make it: make && make test && make install

Usage

Instantiating the client

my $client = ImgurAPI::Client->new( \%optional );

Valid options are:

note that all are optional but the library will throw if its needed and not defined

Authorization

If you haven't already, register an application for an OAuth2 client ID and secret here.

You will need to authorize your OAuth2 application if you haven't already done so. You can get the authorization URL with oauth2_authorize_url:

my $auth_url = $client->oauth2_authorize_url();

# return to user's browser for manual authorization

Once the application has been authorized, the access token, refresh token and expires_in values will be passed to the callback endpoint URL that was specified during application registration. The callback endpoint should collect the values and store them somewhere your client calling code on the backend can pull the access token from and then pass it to the client.

my $access_token = get_access_token_from_some_db();

$client->set_access_token($access_token);

The client library doesn't handle refreshing the access token for you automatically. It is left up to the calling code to refresh the access token when it expires. This is so you can keep the refresh token updated in the database you stored it in initially. The client library is unaware of the database so we leave it up to you to manage.

Requests

Imgur API endpoint subroutines

Account

Album

Comment

Image

Feed

Client member sub-routines

Getters

Setters