# PHP Imgur API Client

Object Oriented PHP wrapper for the Imgur API. 

Uses [Imgur API v3](https://api.imgur.com/).

Please use the Issues section if you encounter any difficulties.

## Requirements

* PHP >= 5.3.2 with [cURL](http://php.net/manual/en/book.curl.php) extension
* [Guzzle](https://github.com/guzzle/guzzle) library

## Composer

Download Composer

```bash
$ curl -s http://getcomposer.org/installer | php
```

Add the library details to your composer.json

```json
"require": {
    "adyg/php-imgur-api-client": "dev-master"
}
```

Install the dependency with

```bash
$ php composer.phar install
```

## Basic usage

```php
<?php
// This file is generated by Composer
require_once 'vendor/autoload.php';

$client = new \Imgur\Client();
$client->setOption('client_id', '[your app client id]');
$client->setOption('client_secret', '[your app client secret]');

if (isset($_SESSION['token'])) {
  $client->setAccessToken($_SESSION['token']);
  if($client->checkAccessTokenExpired()) {
      $client->refreshToken();
  }
}
elseif (isset($_GET['code'])) {
      $client->requestAccessToken($_GET['code']);
      $_SESSION['token'] = $client->getAccessToken();
}
else {
    echo '<a href="'.$client->getAuthenticationUrl().'">Click to authorize</a>';
}
```
The API calls can be accessed via the $client object

```php
<?php
$memes = $client->api('memegen')->defaultMemes();
```

### Uploading an image

Check the Image documentation in the doc/ folder.

## Documentation

Extensive documentation available in the 'doc' directory
