Giter Site home page Giter Site logo

imgurlaravel's Introduction

ImgurLaravel

A Laravel 5.4 package to simplify Imgur Api Client. For detailed information about how to use the Imgur client itself please check the documentation of Imgur Api Client.

Usage

Check the available methods from ImgurLaravel-API.

Image Api Example

<?php

namespace App\Http\Controllers;

use App\Http\Requests;
use Illuminate\Http\Request;

use Kurt\Imgur\Imgur;

class HomeController extends Controller
{
    /**
     * Imgur instance.
     *
     * @var \Kurt\Imgur\Imgur
     */
    private $imgur;

    public function __construct(Imgur $imgur)
    {
        $this->imgur = $imgur;
    }

    /**
     * Retrieve an image by its id.
     * 
     * @return \Imgur\Api\Model\Image
     */
    public function getImage(Request $request)
    {
        $imageApi = $this->imgur->getImageApi();

        $imageModel = $imageApi->image(
            $request->input('id')
        );

        return $imageModel;
    }

    /**
     * Upload an image with a given url or a file.
     * 
     * @return \Imgur\Api\Model\Image
     */
    public function getUpload(Request $request)
    {
        // Upload with a url.
        $imageModel = $this->imgur->uploadFromUrl(
            $request->input('image_url')
        );

        // Upload with a file.
        $imageModel = $this->imgur->upload(
            $request->file('image')
        );

        return $imageModel;
    }
}

Installation

Step 1

Add ozankurt/imgur-laravel to your composer requirements.

composer require ozankurt/imgur-laravel

Step 2

Add the imgur.client_id and imgur.client_secret to the config/services.php file.

    'imgur' => [
        'client_id' => env('IMGUR_CLIENT_ID'),
        'client_secret' => env('IMGUR_CLIENT_SECRET'),
    ],

Step 3

Update your .env file with the values you get from imgur.

You can create the imgur application from here.

IMGUR_CLIENT_ID=
IMGUR_CLIENT_SECRET=

Step 4

Add the service provider to the config/app.php file.

    'providers' => [
        // ...

        Kurt\Imgur\ImgurServiceProvider::class,
    ],

imgurlaravel's People

Contributors

ozankurt avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

imgurlaravel's Issues

Getting uploaded image ID and Link

I am able to upload image success and it return full of information like follows-

Image {#250 ▼
  -id: "u9krQnq"
  -title: null
  -description: null
  -datetime: 1474989221
  -type: null
  -animated: false
  -width: 660
  -height: 330
  -size: 28974
  -views: 0
  -bandwidth: 0
  -deletehash: "bpooLCH1q8W6mKn"
  -section: null
  -link: "http://i.imgur.com/u9krQnq.jpg"
}

Now how can I get link and id?

Help me?

I installed your package. but I have problem
"Undefined variable: imageModel"

Can you update composer.json file?

"adyg/php-imgur-api-client": "^2.0" this package is Abandoned, and change to j0k3r/php-imgur-api-client.

 "require": {
        "adyg/php-imgur-api-client": "^2.0",
        "intervention/image": "^2.3"
    },

change this.

 "require": {
        "j0k3r/php-imgur-api-client": "^3.0.0",
        "intervention/image": "^2.3"
    },

Call to a member function getSuccess() on array

When getting response from imgur api laravel throws this error on

/.../vendor/ozankurt/imgur-laravel/src/Traits/ImageApiHelperTrait.php line 73

seems it calls getSuccess and getData method on the response array?

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.