Code Monkey home page Code Monkey logo

instagram's Introduction

Instagram API for Laravel 5.*

Latest Version on Packagist Software License Total Downloads

Simple Instagram API package for Laravel 5.*. Package is in development, but works - nothing crazy. Always looking for contributors.

Installation

To install, run the following command in your project directory

$ composer require mbarwick83/instagram

Then in config/app.php add the following to the providers array:

Mbarwick83\Instagram\InstagramServiceProvider::class

Also, if you must (recommend you don't), add the Facade class to the aliases array in config/app.php as well:

'Instagram'    => Mbarwick83\Instagram\Facades\Instagram::class

But it'd be best to just inject the class, like so (this should be familiar):

use Mbarwick83\Instagram\Instagram;

Configuration

To publish the packages configuration file, run the following vendor:publish command:

php artisan vendor:publish

This will create a instagram.php in your config directory. Here you must enter your Instagram API Keys. Get your API keys at https://www.instagram.com/developer/clients/register/.

Example Usage

// Get login url:
public function index(Instagram $instagram)
{
	return $instagram->getLoginUrl();
	// or Instagram::getLoginUrl();
}

// Get access token on callback, once user has authorized via above method
public function callback(Request $request, Instagram $instagram)
{
	$response = $instagram->getAccessToken($request->code);
	// or $response = Instagram::getAccessToken($request->code);

    if (isset($response['code']) == 400)
    {
        throw new \Exception($response['error_message'], 400);
    }
    
    return $response['access_token'];
}

Those are the only two custom classes for the API package. The rest of the API works with POST, DELETE and GET requests based on Instagram's end points to keep this package super simple. You can view all the end points here https://www.instagram.com/developer/endpoints/.

All you need to do is specify if the request is a POST, DELETE or GET request, specify just the end point and any URL queries that are required (in an array). For example:

public function index(Instagram $instagram)
{
    $data = $instagram->get('v1/users/self', ['access_token' => $access_token]);
    // $data = $instagram->get('v1/users/' $user-id, ['access_token' => $access_token]);
    return $data;
}

VERY SIMPLE AND EASY!

Contributing

Please see CONTRIBUTING and CONDUCT for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

instagram's People

Contributors

mbarwick83 avatar kikemarto avatar

Watchers

James Cloos avatar Fredrick Njenga 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.