PHPackages                             propeopleua/instagram - 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. propeopleua/instagram

ActiveLibrary[API Development](/categories/api)

propeopleua/instagram
=====================

An easy-to-use PHP Class for accessing Instagram's API.

v2.3(11y ago)01.6k3BSDPHPPHP &gt;=5.2.0

Since Oct 4Pushed 7y ago6 watchersCompare

[ Source](https://github.com/propeopleua/Instagram-PHP-API)[ Packagist](https://packagist.org/packages/propeopleua/instagram)[ Docs](https://github.com/cosenary/Instagram-PHP-API)[ RSS](/packages/propeopleua-instagram/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (4)Used By (0)

[![Image](example/assets/instagram.png)](example/assets/instagram.png) Instagram PHP API V2
===========================================================================================

[](#-instagram-php-api-v2)

> **Note:** Starting today (January 30), we are launching three new features on the Instagram Graph API designed to help businesses better manage their organic presence on Instagram. As part of our API changes, we will also be deprecating the older Instagram API Platform over the next two years beginning on July 31, 2018.Please see the full summary [here](https://developers.facebook.com/blog/post/2018/01/30/instagram-graph-api-updates/).

> **Note:** On the 17 Nov 2015 \[Instagram\]( following endpoints are deprecated immediately:m/post/133424514006/instagram-platform-update) made [changes to their API ](https://instagram.com/developer/changelog/). Apps created before Nov 17, 2015 wont be affected until Jun 2016. Apps created on or after Nov 17 2015 will require to use their updated API. Please note that this library doesn't yet support their new updates. For more information, please see [\#182](https://github.com/cosenary/Instagram-PHP-API/issues/182).

A PHP wrapper for the Instagram API. Feedback or bug reports are appreciated.

[![Total Downloads](https://camo.githubusercontent.com/1b0b25f01f33bd32029c6b27ae80cb89c10ca0b68f332f7c8909a38ffd72d900/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f636f73656e6172792f696e7374616772616d2e7376673f7374796c653d666c6174)](https://packagist.org/packages/cosenary/instagram)[![Latest Stable Version](https://camo.githubusercontent.com/f1fc87e36799bf962a2fd0acb2d2a7c12770ad5215ed47132f6bfab0db8f859b/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f73656e6172792f696e7374616772616d2e7376673f7374796c653d666c6174)](https://packagist.org/packages/cosenary/instagram)[![License](https://camo.githubusercontent.com/5616fb75b97d604749b1e0d04c97b93fe5e2285052d7fa077ddf0b22804f28b4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f636f73656e6172792f696e7374616772616d2e7376673f7374796c653d666c6174)](https://packagist.org/packages/cosenary/instagram)

> [Composer](#installation) package available.
> Supports [Instagram Video](#instagram-videos) and [Signed Header](#signed-header).

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

[](#requirements)

- PHP 5.3 or higher
- cURL
- Registered Instagram App

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

[](#get-started)

To use the Instagram API you have to register yourself as a developer at the [Instagram Developer Platform](http://instagr.am/developer/register/) and create an application. Take a look at the [uri guidelines](#samples-for-redirect-urls) before registering a redirect URI. You will receive your `client_id` and `client_secret`.

---

Please note that Instagram mainly refers to »Clients« instead of »Apps«. So »Client ID« and »Client Secret« are the same as »App Key« and »App Secret«.

---

> A good place to get started is the [example project](example/README.md).

### Installation

[](#installation)

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

```
$ composer require propeopleua/instagram

```

### Initialize the class

[](#initialize-the-class)

```
use MetzWeb\Instagram\Instagram;

$instagram = new Instagram(array(
	'apiKey'      => 'YOUR_APP_KEY',
	'apiSecret'   => 'YOUR_APP_SECRET',
	'apiCallback' => 'YOUR_APP_CALLBACK'
));

echo "Login with Instagram";
```

### Authenticate user (OAuth2)

[](#authenticate-user-oauth2)

```
// grab OAuth callback code
$code = $_GET['code'];
$data = $instagram->getOAuthToken($code);

echo 'Your username is: ' . $data->user->username;
```

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

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

[](#available-methods)

### Setup Instagram

[](#setup-instagram)

`new Instagram(/);`

`array` if you want to authenticate a user and access its data:

```
new Instagram(array(
	'apiKey'      => 'YOUR_APP_KEY',
	'apiSecret'   => 'YOUR_APP_SECRET',
	'apiCallback' => 'YOUR_APP_CALLBACK'
));
```

`string` if you *only* want to access public data:

```
new Instagram('YOUR_APP_KEY');
```

### Get login URL

[](#get-login-url)

`getLoginUrl()`

```
getLoginUrl(array(
	'basic',
	'likes'
));
```

**Optional scope parameters:**

  Scope Legend Methods   `basic` to use all user related methods \[default\] `getUser()`, `getUserFeed()`, `getUserFollower()` etc.   `relationships` to follow and unfollow users `modifyRelationship()`   `likes` to like and unlike items `getMediaLikes()`, `likeMedia()`, `deleteLikedMedia()`   `comments` to create or delete comments `getMediaComments()`, `addMediaComment()`, `deleteMediaComment()` ### Get OAuth token

[](#get-oauth-token)

`getOAuthToken($code, /)`

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

### 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)

**Public methods**

- `getUser($id)`
- `searchUser()`
- `getUserMedia($limit = 0, $min_id = null, $max_id = null)`

**Authenticated methods**

- `getUser()`
- `getUserMedia( )`

> [Sample responses of the User Endpoints.](http://instagram.com/developer/endpoints/users/)

---

### Tag methods

[](#tag-methods)

**Public methods**

- `getTag($name)`
- `getTagMedia($name)`
- `searchTags($name)`

> [Sample responses of the Tag Endpoints.](http://instagram.com/developer/endpoints/tags/)

Instagram videos
----------------

[](#instagram-videos)

Instagram entries are marked with a `type` attribute (`image` or `video`), that allows you to identify videos.

An example of how to embed Instagram videos by using [Video.js](http://www.videojs.com), can be found in the `/example` folder.

---

**Please note:** Instagram currently doesn't allow to filter videos.

---

Signed Header
-------------

[](#signed-header)

In order to prevent that your access tokens gets stolen, Instagram recommends to sign your requests with a hash of your API secret, the called endpoint and parameters.

1. Activate ["Enforce Signed Header"](http://instagram.com/developer/clients/manage/) in your Instagram client settings.
2. Enable the signed-header in your Instagram class:

```
$instagram->setSignedHeader(true);
```

3. You are good to go! Now, all your requests will be secured with a signed header.

Go into more detail about how it works in the [Instagram API Docs](http://instagram.com/developer/restrict-api-requests/#enforce-signed-header).

Pagination
----------

[](#pagination)

Each endpoint has a maximum range of results, so increasing the `limit` parameter above the limit won't help (e.g. `getUserMedia()` has a limit of 90).

That's the point where the "pagination" feature comes into play. Simply pass an object into the `pagination()` method and receive your next dataset:

```
$photos = $instagram->getTagMedia('kitten');

$result = $instagram->pagination($photos);
```

Iteration with `do-while` loop.

Samples for redirect URLs
-------------------------

[](#samples-for-redirect-urls)

  Registered Redirect URI Redirect URI sent to /authorize Valid?     yes     yes     no    [http://yourcallback.com/?this=that&amp;another=true](http://yourcallback.com/?this=that&another=true) yes    [http://yourcallback.com/?another=true&amp;this=that](http://yourcallback.com/?another=true&this=that) no     no     yes > If you need further information about an endpoint, take a look at the [Instagram API docs](http://instagram.com/developer/authentication/).

Example App
-----------

[](#example-app)

[![Image](https://camo.githubusercontent.com/08b9e98726e531de07647c9e4059d2ab45c0bf88155417624cb4ff137b7ba1cf/687474703a2f2f636c2e6c792f696d6167652f32323154316733773375324a2f707265766965772e706e67)](https://camo.githubusercontent.com/08b9e98726e531de07647c9e4059d2ab45c0bf88155417624cb4ff137b7ba1cf/687474703a2f2f636c2e6c792f696d6167652f32323154316733773375324a2f707265766965772e706e67)

This example project, located in the `example/` folder, helps you to get started. The code is well documented and takes you through all required steps of the OAuth2 process. Credit for the awesome Instagram icons goes to [Ricardo de Zoete Pro](http://dribbble.com/RZDESIGN).

Changelog
---------

[](#changelog)

Please see the [changelog file](CHANGELOG.md) for more information.

Credits
-------

[](#credits)

Copyright (c) 2011-2015 - Programmed by Christian Metz

Released under the [BSD License](LICENSE).

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community24

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 68.8% 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 ~55 days

Total

2

Last Release

4230d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0e8b4c73b9ba0729e2c5b690cbdb63bfbe982130513b0c9d64c6c26e1d4d32ff?d=identicon)[BR0kEN-](/maintainers/BR0kEN-)

---

Top Contributors

[![cosenary](https://avatars.githubusercontent.com/u/183625?v=4)](https://github.com/cosenary "cosenary (139 commits)")[![vinkla](https://avatars.githubusercontent.com/u/499192?v=4)](https://github.com/vinkla "vinkla (23 commits)")[![florianbeer](https://avatars.githubusercontent.com/u/800047?v=4)](https://github.com/florianbeer "florianbeer (8 commits)")[![MarioPerezEsteso](https://avatars.githubusercontent.com/u/5071795?v=4)](https://github.com/MarioPerezEsteso "MarioPerezEsteso (3 commits)")[![BR0kEN-](https://avatars.githubusercontent.com/u/2760616?v=4)](https://github.com/BR0kEN- "BR0kEN- (3 commits)")[![GuidoBR](https://avatars.githubusercontent.com/u/1057287?v=4)](https://github.com/GuidoBR "GuidoBR (2 commits)")[![sophiekovalevsky](https://avatars.githubusercontent.com/u/1287883?v=4)](https://github.com/sophiekovalevsky "sophiekovalevsky (2 commits)")[![RobWiddick](https://avatars.githubusercontent.com/u/979864?v=4)](https://github.com/RobWiddick "RobWiddick (2 commits)")[![mgoebelm](https://avatars.githubusercontent.com/u/1482604?v=4)](https://github.com/mgoebelm "mgoebelm (2 commits)")[![mynetx](https://avatars.githubusercontent.com/u/6348321?v=4)](https://github.com/mynetx "mynetx (2 commits)")[![GMusliaj](https://avatars.githubusercontent.com/u/1660253?v=4)](https://github.com/GMusliaj "GMusliaj (2 commits)")[![licvido](https://avatars.githubusercontent.com/u/564821?v=4)](https://github.com/licvido "licvido (2 commits)")[![xpallicer](https://avatars.githubusercontent.com/u/631878?v=4)](https://github.com/xpallicer "xpallicer (1 commits)")[![bitdeli-chef](https://avatars.githubusercontent.com/u/3092978?v=4)](https://github.com/bitdeli-chef "bitdeli-chef (1 commits)")[![brunohoff](https://avatars.githubusercontent.com/u/6672255?v=4)](https://github.com/brunohoff "brunohoff (1 commits)")[![catearcher](https://avatars.githubusercontent.com/u/29156?v=4)](https://github.com/catearcher "catearcher (1 commits)")[![gicolek](https://avatars.githubusercontent.com/u/901183?v=4)](https://github.com/gicolek "gicolek (1 commits)")[![jonathantorres](https://avatars.githubusercontent.com/u/195615?v=4)](https://github.com/jonathantorres "jonathantorres (1 commits)")[![kaloqndamqnov](https://avatars.githubusercontent.com/u/26900282?v=4)](https://github.com/kaloqndamqnov "kaloqndamqnov (1 commits)")[![orarbel](https://avatars.githubusercontent.com/u/708153?v=4)](https://github.com/orarbel "orarbel (1 commits)")

---

Tags

apiinstagram

### Embed Badge

![Health badge](/badges/propeopleua-instagram/health.svg)

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

###  Alternatives

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

Instagram Graph API PHP SDK

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

PHPackages © 2026

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