Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

espresso-dev/instagram-php

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Instagram PHP API

A simple PHP wrapper for the Instagram API. Based on the original Instagram-PHP-API by Christian Metz

Latest Stable Version License Total Downloads

Composer package available.

Requirements

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

Get started

To use the Instagram API, you will need to register a Facebook app and configure Instagram Basic Display. Follow the getting started guide.

Installation

I strongly advise using Composer to keep updates as smooth as possible.

$ composer require espresso-dev/instagram-php

Initialize the class

use EspressoDev\Instagram\Instagram;

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

echo "<a href='{$instagram->getLoginUrl()}'>Login with Instagram</a>";

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

// Set user access token
$instagram->setAccessToken($token);
// Get the users profile
$profile = $instagram->getUserProfile();

echo '<pre>';
print_r($profile);
echo '</pre>';

Get user media

// Set user access token
$instagram->setAccessToken($token);
// Get the users media
$media = $instagram->getUserMedia();

echo '<pre>';
print_r($media);
echo '</pre>';

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.