PHPackages                             ralphmorris/laravel-instagram-feed - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. ralphmorris/laravel-instagram-feed

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

ralphmorris/laravel-instagram-feed
==================================

Adds an OAuth Instagram API integration to a Laravel app

343PHP

Since Feb 19Pushed 7y ago1 watchersCompare

[ Source](https://github.com/ralphmorris/laravel-instagram-feed)[ Packagist](https://packagist.org/packages/ralphmorris/laravel-instagram-feed)[ RSS](/packages/ralphmorris-laravel-instagram-feed/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Laravel Instagram Feed
======================

[](#laravel-instagram-feed)

Adds an OAuth integration with the Instagram API. Allow users to connect their Instagram account to a Laravel App and display their feed.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require ralphmorris/laravel-instagram-feed
```

After installation publish the migration and config file with:

```
php artisan vendor:publish --provider="RalphMorris\LaravelInstagramFeed\LaravelInstagramFeedServiceProvider"
```

Then run:

```
php artisan migrate
```

### Config

[](#config)

Enter your environment variables for your Instagram Client API in your .env file. You can get your API keys by going to  and following the steps to register a new client.

```
instagram_client_id=your-client-id
instagram_client_secret=your-client-secret
```

#### Caching

[](#caching)

By default the package caches the Instagram profiles feed for a period of time. This can be controlled in the published config file.

#### Overriding Used Model

[](#overriding-used-model)

You can also create your own Model, extending the default RalphMorris\\LaravelInstagramFeed\\Models\\InstagramProfile model if you woud like to add your own methods to this class. You can then update the config file with your own model namespace to tell the package to use that instead.

Usage
-----

[](#usage)

Add the HasInstagramTrait trait to your model that is the owner of the Instagram Feed. For example the User model.

```
namespace App;

use Illuminate\Foundation\Auth\User as Authenticatable;
use RalphMorris\LaravelInstagramFeed\Traits\HasInstagramTrait;

class User extends Authenticatable
{
    use HasInstagramTrait;
}
```

See the below controller to view the basic flow of sending the user to the Instagram Authorisation screen, receiving the callback and then retrieving the users Instagram acess token.

This would require two routes to be defined also:

```
Route::get('/instagram-connect', 'InstagramController@connect')->name('instagram.connect');
Route::get('/instagram/callback', 'InstagramController@callback')->name('instagram.callback');
```

```
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use RalphMorris\LaravelInstagramFeed\Instagram;

class InstagramController extends Controller
{
	private $instagram;

    public function __construct(Instagram $instagram)
    {
        $this->instagram = $instagram;
    }

    /**
     * Redirect the user to the Instagram auth page
     *
     * @return Redirect
     */
    public function connect()
    {
        return redirect($this->instagram->getAuthUrl());
    }

    /**
     * Handles Instagram redirect callback on success/error after the user has confirmed/declined
     * the application to access their account.
     *
     * @param  Request $request
     * @return Redirect
     */
    public function callback(Request $request)
    {
        if ($request->error) {
            // handle the error from Instagram in your application
        }

        $data = $this->instagram->retrieveAccessToken($request->code);

        auth()->user()->storeInstagramProfile($data);

        return redirect()->route('home');
    }

}
```

After you have stored your access token in your InstagramProfile model you can get the feed by calling getFeed() on the InstagramProfile instance.

For example:

```
$feed = auth()->user()->instagram->getFeed();
```

API Errors
----------

[](#api-errors)

Occassionally I have had exceptions where fetching the last version of the feed has thrown an error. This is usually because the access\_token has become invalid, possibly as a result of the applications granted permissions being deleted on the Instagram side. When these exceptions occur they are marked in the database as having had an error and the error message stored for review if needed.

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Ralph Morris](https://github.com/ralphmorris)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Laravel Package Boilerplate
---------------------------

[](#laravel-package-boilerplate)

This package was generated using the [Laravel Package Boilerplate](https://laravelpackageboilerplate.com).

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12704880?v=4)[Ralph Morris](/maintainers/ralphmorris)[@ralphmorris](https://github.com/ralphmorris)

### Embed Badge

![Health badge](/badges/ralphmorris-laravel-instagram-feed/health.svg)

```
[![Health](https://phpackages.com/badges/ralphmorris-laravel-instagram-feed/health.svg)](https://phpackages.com/packages/ralphmorris-laravel-instagram-feed)
```

###  Alternatives

[kartik-v/yii2-password

Useful password strength validation utilities for Yii Framework 2.0

761.2M17](/packages/kartik-v-yii2-password)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
