PHPackages                             espresso-dev/instagram-basic-display-php - 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. [API Development](/categories/api)
4. /
5. espresso-dev/instagram-basic-display-php

ActiveLibrary[API Development](/categories/api)

espresso-dev/instagram-basic-display-php
========================================

A simple PHP class for accessing the Instagram Basic Display API

v1.1.7(1y ago)112892.7k—5.1%20[1 PRs](https://github.com/espresso-dev/instagram-basic-display-php/pulls)7MITPHPPHP &gt;=5.6

Since Jan 7Pushed 1y ago11 watchersCompare

[ Source](https://github.com/espresso-dev/instagram-basic-display-php)[ Packagist](https://packagist.org/packages/espresso-dev/instagram-basic-display-php)[ Docs](https://github.com/espresso-dev/instagram-basic-display-php)[ RSS](/packages/espresso-dev-instagram-basic-display-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)DependenciesVersions (12)Used By (7)

*As the Instagram Basic Display API will be deprecated on December 4, 2024  this package is no longer maintained. Please use the [Instagram API PHP](https://github.com/espresso-dev/instagram-php) package instead.*

Instagram Basic Display PHP API
===============================

[](#instagram-basic-display-php-api)

A simple PHP wrapper for the Instagram Basic Display API. Based on the [Instagram-PHP-API](https://github.com/cosenary/Instagram-PHP-API) by [Christian Metz](http://metzweb.net)

[![Latest Stable Version](https://camo.githubusercontent.com/7374a8e105df7a8a589e86f79aeb006e80bb7d08fc7188cdc0a6099f3ad6bf97/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f657370726573736f2d6465762f696e7374616772616d2d62617369632d646973706c61792d7068702e7376673f7374796c653d666c6174)](https://packagist.org/packages/espresso-dev/instagram-basic-display-php)[![License](https://camo.githubusercontent.com/91d71cb1d6ae996cbc760162f5c9d6bd60a70fd0d6709e0840d2884deaf5a53a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f657370726573736f2d6465762f696e7374616772616d2d62617369632d646973706c61792d7068702e7376673f7374796c653d666c6174)](https://packagist.org/packages/espresso-dev/instagram-basic-display-php)[![Total Downloads](https://camo.githubusercontent.com/acf6dac4b2f34e26fe2f1c5cf2a8cecd3e23f738bce2bfdb83b3624195035c4b/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f657370726573736f2d6465762f696e7374616772616d2d62617369632d646973706c61792d7068702e7376673f7374796c653d666c6174)](https://packagist.org/packages/espresso-dev/instagram-basic-display-php)

> [Composer](#installation) package available.

Requirements
------------

[](#requirements)

- PHP 5.6 or higher
- cURL
- Facebook Developer Account
- Facebook App

Get started
-----------

[](#get-started)

To use the [Instagram Basic Display API](https://developers.facebook.com/docs/instagram-basic-display-api), you will need to register a Facebook app and configure Instagram Basic Display. Follow the [getting started guide](https://developers.facebook.com/docs/instagram-basic-display-api/getting-started).

### Installation

[](#installation)

I strongly advice using [Composer](https://getcomposer.org) to keep updates as smooth as possible.

```
$ composer require espresso-dev/instagram-basic-display-php

```

### Initialize the class

[](#initialize-the-class)

```
use EspressoDev\InstagramBasicDisplay\InstagramBasicDisplay;

$instagram = new InstagramBasicDisplay([
    'appId' => 'YOUR_APP_ID',
    'appSecret' => 'YOUR_APP_SECRET',
    'redirectUri' => 'YOUR_APP_REDIRECT_URI'
]);

echo "Login with Instagram";
```

### Authenticate user (OAuth2)

[](#authenticate-user-oauth2)

```
// Get the OAuth callback code
$code = $_GET['code'];

// Get the short lived access token (valid for 1 hour)
$token = $instagram->getOAuthToken($code, true);

// Exchange this token for a long lived token (valid for 60 days)
$token = $instagram->getLongLivedToken($token, true);

echo 'Your token is: ' . $token;
```

### Get user profile

[](#get-user-profile)

```
// Set user access token
$instagram->setAccessToken($token);

// Get the users profile
$profile = $instagram->getUserProfile();

echo '';
print_r($profile);
echo '';
```

**All methods return the API data as `json_decode()` - so you can directly access the data.**

Available methods
-----------------

[](#available-methods)

### Setup Instagram

[](#setup-instagram)

`new Instagram(/);`

`array` if you want to perform oAuth:

```
new InstagramBasicDisplay([
    'appId' => 'YOUR_APP_ID',
    'appSecret' => 'YOUR_APP_SECRET',
    'redirectUri' => 'YOUR_APP_REDIRECT_URI'
]);
```

`string` once you have a token and just want to return *read-only* data:

```
new InstagramBasicDisplay('ACCESS_TOKEN');
```

### Get login URL

[](#get-login-url)

`getLoginUrl(, )`

```
getLoginUrl(
    array(
        'user_profile',
        'user_media'
    ),
    'state'
);
```

### Get OAuth token (Short lived valid for 1 hour)

[](#get-oauth-token-short-lived-valid-for-1-hour)

`getOAuthToken($code, /)`

`true` : Returns only the OAuth token
`false` *\[default\]* : Returns OAuth token and profile data of the authenticated user

### Exchange the OAuth token for a Long lived token (valid for 60 days)

[](#exchange-the-oauth-token-for-a-long-lived-token-valid-for-60-days)

`getLongLivedToken($token, /)`

`true` : Returns only the OAuth token
`false` *\[default\]* : Returns OAuth token and profile data of the authenticated user

### Refresh access token for another 60 days before it expires

[](#refresh-access-token-for-another-60-days-before-it-expires)

`refreshToken($token, /)`

`true` : Returns only the OAuth token
`false` *\[default\]* : Returns OAuth token and expiry data of the token

### Set / Get access token

[](#set--get-access-token)

- Set the access token, for further method calls: `setAccessToken($token)`
- Get the access token, if you want to store it for later usage: `getAccessToken()`

### User methods

[](#user-methods)

**Authenticated methods**

- `getUserProfile()`
- `getUserMedia(, )`
    - if an `$id` isn't defined or equals `'me'`, it returns the media of the logged in user

### Media methods

[](#media-methods)

**Authenticated methods**

- `getMedia($id)`
- `getMediaChildren()`

Pagination
----------

[](#pagination)

The `getUserMedia` endpoint has a maximum range of results, so increasing the `limit` parameter above the limit of 99 won't help.You can use pagination to return more results for this endpoint.

Pass an object into the `pagination()` method and receive your next dataset:

```
$media = $instagram->getUserMedia();

$moreMedia = $instagram->pagination($media);
```

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity54

Moderate usage in the ecosystem

Community29

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 64.5% of commits — single point of failure

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.

###  Release Activity

Cadence

Every ~191 days

Recently: every ~402 days

Total

10

Last Release

602d ago

PHP version history (3 changes)v1.0PHP &gt;=7.2.0

v1.0.1PHP &gt;=7

v1.1.4PHP &gt;=5.6

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/254865472?v=4)[espressodev](/maintainers/espressodev)[@espressodev](https://github.com/espressodev)

---

Top Contributors

[![hermanschutte](https://avatars.githubusercontent.com/u/767120?v=4)](https://github.com/hermanschutte "hermanschutte (20 commits)")[![rvalitov](https://avatars.githubusercontent.com/u/16267156?v=4)](https://github.com/rvalitov "rvalitov (5 commits)")[![movingwater](https://avatars.githubusercontent.com/u/8091819?v=4)](https://github.com/movingwater "movingwater (2 commits)")[![curruwilla](https://avatars.githubusercontent.com/u/7454081?v=4)](https://github.com/curruwilla "curruwilla (1 commits)")[![hermanespresso](https://avatars.githubusercontent.com/u/53303339?v=4)](https://github.com/hermanespresso "hermanespresso (1 commits)")[![benegetto](https://avatars.githubusercontent.com/u/26416445?v=4)](https://github.com/benegetto "benegetto (1 commits)")[![jtfuel76](https://avatars.githubusercontent.com/u/64226092?v=4)](https://github.com/jtfuel76 "jtfuel76 (1 commits)")

---

Tags

apiinstagram

### Embed Badge

![Health badge](/badges/espresso-dev-instagram-basic-display-php/health.svg)

```
[![Health](https://phpackages.com/badges/espresso-dev-instagram-basic-display-php/health.svg)](https://phpackages.com/packages/espresso-dev-instagram-basic-display-php)
```

###  Alternatives

[jstolpe/instagram-graph-api-php-sdk

Instagram Graph API PHP SDK

13998.4k2](/packages/jstolpe-instagram-graph-api-php-sdk)

PHPackages © 2026

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