1. Go to this page and download the library: Download tranghaviet/imgur-laravel 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/ */
tranghaviet / imgur-laravel example snippets
use Redeman\Imgur\Facades\Imgur;
$images = Imgur::api('gallery')->randomGalleryImages();
foreach ($images as $image)
{
echo '<li><img src="' . $image->getLink() . '"></li>';
}
/**
* The application's route middleware.
*
* @var array
*/
protected $routeMiddleware = [
// your other route middleware
'imgur' => \Redeman\Imgur\Middleware\AuthenticateImgur::class,
];
// Show the user a random image
Route::get('/', function() {
$client = App::make('Imgur\Client');
$images = $client->api('gallery')->randomGalleryImages();
return view('imgur.images')->with('images', $images);
})->middleware('imgur');
// Ask the user to authenticate using Imgur's services
Route::get('imgur/authenticate', ['as' => 'imgur.authenticate', function() {
$client = App::make('Imgur\Client');
return view('imgur.authenticate')->with('imgurUrl', $client->getAuthenticationUrl());
}]);
/*
* Public client id
*/
'client_id' => env('CLIENT_ID'),
/**
* Client secret
*/
'client_secret' => env('CLIENT_SECRET'),