1. Go to this page and download the library: Download espresso-dev/instagram-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
espresso-dev / instagram-php example snippets
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>";
// 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;
// Set user access token
$instagram->setAccessToken($token);
// Get the users profile
$profile = $instagram->getUserProfile();
echo '<pre>';
print_r($profile);
echo '</pre>';
// Set user access token
$instagram->setAccessToken($token);
// Get the users media
$media = $instagram->getUserMedia();
echo '<pre>';
print_r($media);
echo '</pre>';
bash
$ composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.