Skip to the content.

Instagram PHP SDK

An unofficial PHP SDK for the Instagram Graph API, covering Instagram Business Login, comments, direct messages and webhook subscriptions.

composer require amirsarhang/instagram-php-sdk
use Amirsarhang\Instagram;

$instagram = new Instagram($accessToken);

$instagram->comments()->reply($commentId, 'Thanks!');
$instagram->messages()->sendText($userId, 'Hello there');
$instagram->webhooks()->subscribe(['messages', 'comments']);

Documentation

Page What it covers
Installation Requirements, the HTTP client, and configuration
Authentication Business Login, access tokens, refreshing
Comments Reading, replying, hiding and deleting
Messages Reading and sending direct messages
Webhooks Subscribing to real time events
Account The profile behind the access token
Raw requests Endpoints the SDK does not wrap yet
Error handling The exception hierarchy and Graph error codes
Upgrading to 4.x What changed and how to migrate

Requirements

PHP Version Package Version Connection Type Required Parameters
>= 7.0 1.x Facebook Graph Login FACEBOOK_APP_ID \| FACEBOOK_APP_SECRET
>= 8.0 2.x Facebook Graph Login FACEBOOK_APP_ID \| FACEBOOK_APP_SECRET
>= 8.0 3.x Instagram Graph Login INSTAGRAM_APP_ID \| INSTAGRAM_APP_SECRET
>= 8.0 4.x Instagram Graph Login INSTAGRAM_APP_ID \| INSTAGRAM_APP_SECRET

You need a verified Meta app to use this SDK in production.