yongyongjiejie1995 / KingOfInstagram

Instagram Session
0 stars 0 forks source link

Instagram Session #1

Open yongyongjiejie1995 opened 9 years ago

yongyongjiejie1995 commented 9 years ago

IntegrateLogin.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); 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 '<img src='.$data->user->profile_picture.'>';

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);

// Store user access token

$instagram->setAccessToken($data); // Your uploaded images $popular = $instagram->getUserMedia($data->user->id); foreach ($popular->data as $data) { echo ''; }

}

?>

yongyongjiejie1995 commented 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?