<?php

if (empty($customer_id)) {
    $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;
Ejemplo n.º 2
0
Archivo: index.php Proyecto: 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>
 function update_value($value, $post_id, $field)
 {
     $data = array('shortcode' => $value, 'raw_json' => '');
     // Check Transient
     $transient_name = 'instagram-media-' . $value;
     if (false === ($media = get_transient($transient_name))) {
         // Fetch Media info
         if ($field['client_id'] && $field['client_secret']) {
             require_once dirname(__FILE__) . '/Instagram.php';
             $instagram = new MetzWeb\Instagram\Instagram($field['client_id']);
             $response = $instagram->getMediaShortcode($value);
             if ($response->meta->code == 200) {
                 // Save Media Object
                 $json = base64_encode(json_encode($response->data));
                 $data['raw_json'] = $json;
                 // Save Transient
                 set_transient($transient_name, $json, $field['cache_lifetime']);
             } else {
                 throw new \Exception($respons->meta->error_type . ':' . $respons->meta->code . ':' . $respons->meta->error_message);
             }
         }
     } else {
         $data['raw_json'] = $media;
     }
     return $data;
 }
Ejemplo n.º 4
0
 * TITLE: Сообщество
 * AVAILABLE_ONLY_IN_ADVANCED_MODE
 */
?>
@extends(Helper::layout())
<?php 
##
## Instagram Photos
##
$instagram_cache_key = 'instagram_data';
$media = null;
#Cache::forget($instagram_cache_key);
if (Cache::has($instagram_cache_key)) {
    $media = Cache::get($instagram_cache_key);
} else {
    $instagram = new MetzWeb\Instagram\Instagram(Config::get('site.instagram.api'));
    $result = $instagram->searchUser(Config::get('site.instagram.account_name'), 1);
    $account_id = $result->data[0]->id;
    #$account_id = Config::get('site.instagram.account_id');
    #dd($account_id);
    $result = $instagram->getUserMedia($account_id, 5);
    #Helper::dd($result);
    if (isset($result) && is_object($result) && $result->meta->code == 200) {
        $media = $result->data;
        Cache::add($instagram_cache_key, $media, 15);
    }
}
#Helper::dd($media);
##
## Paginator Set Current Page - It is WORK!!
## http://stackoverflow.com/questions/17386641/specify-a-page-for-pagination-laravel-4