PHP code example of arf / imgur

1. Go to this page and download the library: Download arf/imgur library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

arf / imgur example snippets


'Imgur' => Arf\Imgur\Facades\Upload::class,

Imgur::upload($args);

Imgur::get($id);

Imgur::update($image, $id);

Imgur::delete($id);


Imgur::setHeaders([
    'headers' => [
        'authorization' => 'Client-ID ' . env('IMGUR_CLIENT_ID'),
        'content-type' => 'application/x-www-form-urlencoded',
    ]
])->setFormParams([
    'form_params' => [
        'image' => $image,
    ]
])->upload($image);

$image = Imgur::upload($file);

// Get imgur image link.
$image->link(); //"https://i.imgur.com/XN9m1nW.jpg"

// Get imgur image file size.
$image->fileszie(); //43180

// Get imgur image file type.
$image->type(); //"image/jpeg"

// Get imgur image width.
$image->width(); //480

// Get imgur image height.
$image->height(); //640

// Or you can get usual data.
$image->usual();

//[
//  'link' => "https://i.imgur.com/XN9m1nW.jpg",
//  'filesize' => 43180,
//  'type' => "image/jpeg",
//  'width' => 480,
//  'height' => 640,
//]

$image = Imgur::upload($file);

// Support: https://api.imgur.com/models/image

// Get small square.
$small_square = Imgur::size($image->link(), 's');

// Get big square thumbbnail.
$small_square = Imgur::size($image->link(), 'b');

// Get small small thumbbnail.
$small_square = Imgur::size($image->link(), 't');

// Get small medium thumbbnail.
$small_square = Imgur::size($image->link(), 'm');

// Get small large thumbbnail.
$small_square = Imgur::size($image->link(), 'l');

// Get small huge thumbbnail.
$small_square = Imgur::size($image->link(), 'h');
 php

//app.php
'providers' => [
    Arf\Imgur\UploadServiceProvider::class,
],
bash
$ php artisan vendor:publish