File: //home/artinside/public_html/lhh/auth.php
<?php
require __DIR__ . "/vendor/autoload.php";
use EspressoDev\InstagramBasicDisplay\InstagramBasicDisplay;
$instagram = new InstagramBasicDisplay("IGQVJWMkJNakUyNVppcldnMU1WREdnclFmSGRFemVOYWxwazlqY1FKUURDOEdXSG1GQlB0azJYYnU3WDR2bTlGbUJIU0hCN3c5MGFsMDYtY1NOT29KemVhQTZAUU1JyQy1fbzFybU5R");
// 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("IGQVJWMkJNakUyNVppcldnMU1WREdnclFmSGRFemVOYWxwazlqY1FKUURDOEdXSG1GQlB0azJYYnU3WDR2bTlGbUJIU0hCN3c5MGFsMDYtY1NOT29KemVhQTZAUU1JyQy1fbzFybU5R");
// Get the users profile
$profile = $instagram->getUserProfile();
echo '<pre>';
print_r($profile);
echo '<pre>';
$media = $instagram->getUserMedia("me", 1);
//var_dump($media);
$upload = new \Source\Support\Upload();
foreach ($media->data as $item) {
if($item->media_type == "IMAGE"){
echo "<img src='".$item->media_url."' width='500' height='500'>";
$content = file_get_contents($item->media_url);
//Store in the filesystem.
$fp = fopen("tmp/teste.jpg", "w");
fwrite($fp, $content);
fclose($fp);
}
//Get the file
}