<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
espresso-dev / instagram-basic-display-php example snippets
use EspressoDev\InstagramBasicDisplay\InstagramBasicDisplay;
$instagram = new InstagramBasicDisplay([
'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>';