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;
}
Beispiel #2
0
<?php

require_once './api/Instagram.class.php';
$username = isset($_GET['user']) ? $_GET['user'] : NULL;
$count = isset($_GET['count']) && is_numeric($_GET['count']) ? $_GET['count'] : 12;
$token = '<PUT YOUR TOKEN HERE>';
$api = new Instagram($token);
$id = $api->getUserId($username);
$photos = $api->getUserPhotos($id, $count);
header('Content-type: application/json');
echo $photos;