$instagram_client_id = $config['instagram_login']['instagram_login_client_id'];
 $instagram_client_secret = $config['instagram_login']['instagram_login_client_secret'];
 $instagram_redirect_url = $http_location . '/index.php?action=instagram_login';
 //'http://dev.cartworks.com/product_stages/index.php?action=instagram_login'; //path to your script
 //include instagram api files
 cw_include('addons/instagram_login/include/src/Instagram.php');
 $instagram = new MetzWeb\Instagram\Instagram(array('apiKey' => $instagram_client_id, 'apiSecret' => $instagram_client_secret, 'apiCallback' => $instagram_redirect_url));
 $instagram_login_info =& cw_session_register('instagram_login_info');
 //If code is empty, redirect user to instagram authentication page for code.
 //Code is required to aquire Access Token from instagram
 //Once we have access token, assign token to session variable
 //and we can redirect user back to page and login.
 if (isset($_GET['code'])) {
     if ($_GET['action'] == 'instagram_login') {
         // receive OAuth token object
         $data = $instagram->getOAuthToken($_GET['code']);
         // store user access token
         $instagram->setAccessToken($data);
         // now you have access to all authenticated user methods
         $result = $instagram->getUserMedia();
         $instagram_login_info['data'] = $data;
         $instagram_login_info['result'] = $result;
     }
 }
 if ($instagram_login_info['data']->user->id) {
     //For logged in user, get details from instagram using access token
     $instagram_user_id = $instagram_login_info['data']->user->id;
     $instagram_uname = $instagram_login_info['data']->user->username;
     $instagram_user_name = $instagram_login_info['data']->user->full_name;
     if (empty($instagram_user_name)) {
         $instagram_user_name = $instagram_uname;
Exemplo n.º 2
0
Arquivo: index.php Projeto: nuiz/api2
<?php

require "../bootstrap.php";
$instagram = new MetzWeb\Instagram\Instagram(array('apiKey' => '2edda6ebe18d4422b609c93bda5744f9', 'apiSecret' => '5c23e7f88dcf4c45827fb59692665e02', 'apiCallback' => 'http://api1.papangping.com/instragram'));
if (empty($_SESSION['instragram']) && empty($_GET['code'])) {
    header("Location: " . $instagram->getLoginUrl());
    exit;
}
if (!empty($_GET['code'])) {
    $code = $_GET['code'];
    $data = $instagram->getOAuthToken($code);
    $_SESSION['instragram'] = $data;
    header("Location: index.php");
    exit;
}
?>
<html>
<head>
	<meta charset="utf-8">
	<script type="text/javascript" src="public/jquery/jquery-1.11.3.min.js"></script>
</head>
<body>
<div>
<img src="<?php 
echo $_SESSION['instragram']->user->profile_picture;
?>
"> <strong><?php 
echo $_SESSION['instragram']->user->username;
?>
</strong>
<div>