Skip to content

billmalarky/php-imgur-api-client

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Note: If you aren't me do not use this fork.

Use the original from Adyg https://github.com/Adyg/php-imgur-api-client. I mean, it's a free country, but I'm not maintaining this for general use so expect bugs.

PHP Imgur API Client

Object Oriented PHP wrapper for the Imgur API.

Uses Imgur API v3.

Please use the Issues section if you encounter any difficulties.

Requirements

Composer

Download Composer

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

Add the library details to your composer.json

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

Install the dependency with

$ php composer.phar install

Basic usage

<?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
$memes = $client->api('memegen')->defaultMemes();

Uploading an image

Check the Image documentation in the doc/ folder.

Documentation

Extensive documentation available in the 'doc' directory

About

Object Oriented PHP wrapper for the Imgur API.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%