Beispiel #1
0
require_once 'config.php';
require_once 'Class.Instagram.php';
if (isset($_GET['error']) && $_GET['error'] != "") {
    echo "You Need to grant access to the application in order to continue!";
    exit;
}
if (isset($_GET['code']) && $_GET['code'] != "") {
    /**
     * InstaGram redirected to our URL with Code
     * So use this code to get Access Token from InstaGram for further opeartions
     */
    $instgram = new Instagram();
    $accesstoken = $instgram->getAccessTokenFromCode($_GET['code']);
    if ($accesstoken != "") {
        $_SESSION['AccessToken'] = $accesstoken;
        $_SESSION['UserId'] = $instgram->getUserId();
        $_SESSION['FullName'] = $instgram->getUserFullName();
        $_SESSION['Thumbnail'] = $instgram->getUserThumb();
        header("Location: index.php");
        exit;
    }
}
/**
 * If op is set to "getauth" it means user has not been authorized so we need to redirect user to Instagram server
 * and get authorization code
 *
 */
if (isset($_GET['op']) && $_GET['op'] == "getauth") {
    header("Location: " . sprintf($urlconfig['authorization_url'], $appconfig['client_id'], $appconfig['redirect_url']));
    exit;
}