Open yongyongjiejie1995 opened 9 years ago
I don't why once I login through integratelogin.php to hompage.php, the session works. But once I go InstagramPhotoAlbum.php through homepage.php by button, the session is cancel at InstagramPhotoAlbum.php. So how do I solve this problem?
IntegrateLogin.php <?php require 'instagram.class.php'; require 'config.php';
));
$code = $_GET['code'];
if (true === isset($code)) { $data = $instagram->getOAuthToken($code); header( 'Location: http://nypsitdev.edu.sg/fypj/fypj131127C/FYP/HomePage.php' ) ;
} else { $loginUrl = $instagram->getLoginUrl(); echo "<a class=\"button\" href=\"$loginUrl\">Sign in with Instagram"; } ?>
HomePage.php
<?php session_start(); require 'instagram.class.php'; require 'config.php'; $instagram = new Instagram(array( 'apiKey' => YOUR_APP_KEY, 'apiSecret' => YOUR_APP_SECRET, 'apiCallback' => YOUR_APP_CALLBACK ));
$instagram->setAccessToken($data); $code = $_GET['code']; session_start(); if (true === isset($code)) { $data = $instagram->getOAuthToken($code);
echo 'Welcome ' . $data->user->username . '!!!';
}
?>
InstagramPhotoAlbum.php
<?php
require 'instagram.class.php'; require 'config.php'; $instagram = new Instagram(array( 'apiKey' => YOUR_APP_KEY, 'apiSecret' => YOUR_APP_SECRET, 'apiCallback' => YOUR_APP_CALLBACK ));
$code = $_GET['code']; if (true === isset($code)) { $data = $instagram->getOAuthToken($code);
$instagram->setAccessToken($data); // Your uploaded images $popular = $instagram->getUserMedia($data->user->id); foreach ($popular->data as $data) { echo ''; }
}
?>