GithubHelp home page GithubHelp logo

codeigniter-imgur's Introduction

Imgur API wrapper for anonymous resources

Imgur API provides easy way to handle images, the library makes it possible to use the API's anonymous resources

Installation

Get your API key from imgur.com

If you use this package in conventional way, then copy the files to their appropriate folders, and set up the config file.

$config['imgur_apikey']   = ''; // Imgur API key
$config['imgur_format']   = 'json'; // json OR xml
$config['imgur_xml_type'] = 'object'; // array OR object

Installing this package as spark:

php tools/spark install -v1.0.0 imgur

Implemented methods

  • move_image() /Sideloading/
  • upload()
  • stats()
  • album()
  • image()
  • delete()
  • oembed()

Usage

Load the spark:

$this->load->spark('imgur/1.0.0');  

OR load the library

$this->load->library('imgur');

move_image()

Image sideloading allows you to move an image from another web host onto Imgur

$params = array(
    'url'  => 'http://yoursite.com/picture.jpg',
    'edit' => FALSE
);

$response = $this->imgur->move_image($params);

If you wish to edit the image first, set edit to TRUE

upload()

Uploads an image

Upload from url:

$params = array(
    'image'   => 'http://yoursite.com/picture.jpg',
    'type'    => 'url', // optional
    'name'    => 'image.jpg', // optional
    'title'   => 'Picture name', // optional
    'caption' => 'Picture caption' // optional
);

Upload from file:

$params = array(
    'image' => base64_encode(file_get_contents(FCPATH . 'picture.jpg')),			
    'type'  => 'base64'
);

$response = $this->imgur->upload($params);

stats()

Display site statistics, such as bandwidth usage, images uploaded, image views, and average image size

$response = $this->imgur->stats('month');

Possible parameters: 'today', 'week', 'month'

album()

Returns album information and lists all images that belong to the album

$response = $this->imgur->album($id);

image()

Returns all the information about a certain image

$response = $this->imgur->image($hash);

delete()

Deletes an image

$response = $this->imgur->delete($delete_hash);

oembed()

Oembed allows you to make a request for an album or image URL and it will return the embed code as well as additional information about the object. For additional information please see the oembed documentation

$params = array(
    'url'       => 'http://i.imgur.com/xxxxx.png',
    'format'    => 'json', // optional
    'maxheight' => 200, // optional
    'maxwidth'  => 200 // optional
);

$response = $this->imgur->oembed($params);

Return values

As you set in the config file, you can get json or xml(array or object) return values. If you get back FALSE result, check your log file

Requirements

cURL spark/library by Phil Sturgeon

Note

It's for the anonymous resources, maybe I'll do a library later for OAuth authenticated resources

License

MIT License

C. 2012 Barna Szalai ([email protected])

codeigniter-imgur's People

Watchers

James Cloos avatar Azhar nian avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.