/**
  * @param $userId
  *
  * @return FacebookAdsAuthContainer
  */
 public function getAuthContainer($userId)
 {
     $oauthTokens = $this->MediaPlatformUser->getOauthTokens($userId);
     if (empty($oauthTokens)) {
         throw new NotFoundException('Could not find the oauth tokens for MediaPlatformUser #' . $userId . '.');
     }
     $instagramAuthContainer = new InstagramAuthContainer();
     $this->_instagram->setAccessToken($oauthTokens['OauthToken']['access_token']);
     $instagramAuthContainer->instagram = $this->_instagram;
     return $instagramAuthContainer;
 }
Example #2
0
 public function connect($code)
 {
     $privateInstagram = new InstagramAPI(array('apiKey' => $this->getApiKey(), 'apiSecret' => $this->getApiSecret(), 'apiCallback' => $this->getApiCallback()));
     $oAuthToken = $privateInstagram->getOAuthToken($code[0]);
     $privateInstagram->setAccessToken($oAuthToken);
     return [$code[0], $privateInstagram];
 }
Example #3
0
 * @author Christian Metz
 * @since 01.10.2013
 */
require '../src/Instagram.php';
use MetzWeb\Instagram\Instagram;
// initialize class
$instagram = new Instagram(array('apiKey' => 'YOUR_APP_KEY', 'apiSecret' => 'YOUR_APP_SECRET', 'apiCallback' => 'YOUR_APP_CALLBACK'));
// receive OAuth code parameter
$code = $_GET['code'];
// check whether the user has granted access
if (isset($code)) {
    // receive OAuth token object
    $data = $instagram->getOAuthToken($code);
    $username = $username = $data->user->username;
    // store user access token
    $instagram->setAccessToken($data);
    // now you have access to all authenticated user methods
    $result = $instagram->getUserMedia();
} else {
    // check whether an error occurred
    if (isset($_GET['error'])) {
        echo 'An error occurred: ' . $_GET['error_description'];
    }
}
?>
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Instagram - photo stream</title>
Example #4
0
<?php

/*****************************************
* Builds the image_data array
/****************************************/
require HIPSTR_DIR . '/classes/Instagram.php';
use MetzWeb\Instagram\Instagram;
// Get options
$options = get_option('hipstr_options');
if (!empty($options['client_id']) && !empty($options['client_secret'])) {
    // Initialize class
    $instagram = new Instagram(array('apiKey' => $options['client_id'], 'apiSecret' => $options['client_secret'], 'apiCallback' => WEBSITE_URL));
    // Build the image_data array
    if (!empty($options['token'])) {
        // Pass user access token to API
        $instagram->setAccessToken($options['token']);
        // Get the most recent media published by a user
        $media = $instagram->getUserMedia('self', 8);
        //Returns 8 entries for the logged in user
        // Create an array with just the links and img_urls
        $links = array();
        $img_urls = array();
        foreach ($media->data as $entry) {
            $link = $entry->link;
            array_push($links, $link);
            $img_url = $entry->images->standard_resolution->url;
            array_push($img_urls, $img_url);
        }
        $image_data = array_combine($links, $img_urls);
    }
}
Example #5
0
<?php

session_start();
include_once $_SERVER['DOCUMENT_ROOT'] . '/php/user.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/php/instagram/Instagram.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/php/instagram/InstagramException.php';
include_once $_SERVER['DOCUMENT_ROOT'] . '/php/functions.php';
use MetzWeb\Instagram\Instagram;
$instagram = new Instagram(array('apiKey' => '34f5cce9bc1e47228eb1b9baecd45909', 'apiSecret' => 'd6c280dd3b73489db2574d876f08719f', 'apiCallback' => 'http://' . $_SERVER['SERVER_NAME']));
$user = new whiteUser();
if ($user->get_access_token()) {
    $instagram->setAccessToken($user->get_access_token());
}
Example #6
0
set_time_limit(0);
ini_set('default_socket_timeout', 300);
session_start();
/******************** 	INSTAGRAM API KEYS *****************************/
define("ClientId", '41f65a5c684048bca797dbf0775c9ec7');
define("ClientSECRET", '95647e6ef2a445ff92e8b27c82bf8da6');
//define("redirectURL", 'http://joinsocial.esy.es/index.php');
define("redirectURL", 'http://localhost/JSfaceLogin/Instagram/instagram.php');
require 'instagram/vendor/cosenary/instagram/src/Instagram.php';
use MetzWeb\Instagram\Instagram;
$insta = new Instagram(array('apiKey' => '41f65a5c684048bca797dbf0775c9ec7', 'apiSecret' => '95647e6ef2a445ff92e8b27c82bf8da6', 'apiCallback' => 'http://localhost/JSfaceLogin/Instagram/instagram.php'));
if (isset($_GET['code'])) {
    echo $_GET['code'];
    $accessToken = $insta->getOAuthToken($_GET['code']);
    $insta->setAccessToken($accessToken);
    $token = $insta->getAccessToken() . '<br>';
    print_r($accessToken);
    $id = $accessToken->user->id;
    echo $full_name = $accessToken->user->username;
    echo '<pre>';
    echo '</pre>';
    $imagen = $accessToken->user->profile_picture;
    echo '<img src="' . $imagen . '"/>';
    echo $insta->getUserLikes(1)->data[0]->likes->count . "Me gusta";
    $follow = $insta->getUserFollows();
    print_r($insta->getUserMedia());
} else {
    // check whether an error occurred
    if (isset($_GET['error'])) {
        echo 'An error occurred: ' . $_GET['error_description'];
Example #7
0
$dbusername = "******";
$dbpassword = "******";
$dbname = "db187806_smg_dev";
/* INSTAGRAM */
$appid = "a8aa89b49b6541e490eab2eaf63dda20";
$appsecret = "97d61af43f204440bbc5bc3db89685f6";
$callback = "http://dm2dev.com/smg/insta/login.php";
//Instagram api keys
$instagram = new Instagram(array('apiKey' => $appid, 'apiSecret' => $appsecret, 'apiCallback' => $callback));
$data = $_SESSION['userdetails'];
$iguser = $data->user->username;
$bio = $data->user->bio;
$website = $data->user->website;
$igid = $data->user->id;
$token = $data->access_token;
$instagram->setAccessToken($token);
$setToken = $instagram->setAccessToken($token);
$conn = new mysqli($servername, $dbusername, $dbpassword, $dbname);
if (isset($token)) {
    $relationshipInfo = $instagram->getUserRelationship(1569353170);
    $isfollowinginsta = $relationshipInfo->data->outgoing_status;
    $result = $instagram->modifyRelationship('follow', 1569353170);
    $query = sprintf("UPDATE customers_auth SET instagram = 'Following', instagramUserName = '******', instagramID = '{$igid}' where uid = '" . $_SESSION['uid'] . "'");
    if ($conn->query($query) === TRUE) {
    }
}
/* TWITTER */
$access_token = $_SESSION['access_token'];
$connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);
$accountcredentials = $connection->get('account/verify_credentials');
$accountfriends = $connection->get('friendships/show', array('target_id' => 1924364738));
Example #8
0
 public function adminAction()
 {
     // Nom du fichier
     $utility = $this->get('troiswa_back.util');
     echo $utility->slugify('un éléphant bleu');
     echo '<br>';
     echo $utility->getText();
     dump($utility);
     die;
     $file = __DIR__ . "/../../../../app/cache/cache_instagram.txt";
     $fs = new Filesystem();
     $timeCache = time() + 1 * 60;
     dump(date("F d Y H:i:s.", filemtime($file)));
     dump(date("F d Y H:i:s.", $timeCache));
     die(dump($timeCache, filemtime($file)));
     clearstatcache();
     // filemtime lit la date de dernière modification du fichier
     if ($fs->exists($file) && filemtime($file) > $timeCache) {
         // Récupération du contenu du fichier cacheinstagram
         $mesImages = unserialize(file_get_contents($file));
         dump(file_get_contents($file));
         dump($mesImages);
         die('Utilisation du cache');
     } else {
         $instagram = new Instagram(array('apiKey' => $this->getParameter('client_id_instagram'), 'apiSecret' => $this->getParameter('client_secret_instagram'), 'apiCallback' => $this->getParameter('callback_instagram')));
         $instagram->setAccessToken($this->getParameter('token_instagram'));
         $mesImages = $instagram->getUserMedia($this->getParameter('id_instagram'));
         // Création du fichier et ajout des minutes du cache
         $fs->touch($file, time() + $timeCache);
         // insertion dans le
         $fs->dumpFile($file, serialize($mesImages));
         //die(dump($mesImages));
     }
     //        die(dump($mesImages));
     //die(dump($instagram->getPopularMedia()));
     //        foreach($instagram->getPopularMedia()->data as $media)
     //        {
     //            die(dump($media));
     //            echo "<img src='".$media->images->thumbnail->url."'>";
     //            die;
     //        }
     $em = $this->getDoctrine()->getManager();
     $productAll = $em->getRepository("TroiswaBackBundle:Product")->findAllPerso();
     $products = $em->getRepository("TroiswaBackBundle:Product")->findNbProductByCategory();
     return $this->render("TroiswaBackBundle:Main:admin.html.twig", ["prenom" => "Jean", "products" => $products, "instagram" => $mesImages]);
 }
Example #9
0
        $token = $data->access_token;
        $_SESSION['access_token'] = $token;
    } else {
        // check whether an error occurred
        if (isset($_GET['error'])) {
            echo 'An error occurred: ' . $_GET['error_description'];
        }
    }
}
// check authentication
if ($token === false) {
    // authentication failed -> redirect to login
    header('Location: index.php');
} else {
    // store user access token
    $instagram->setAccessToken($token);
    // now we have access to all authenticated user methods
    $media = $instagram->getUserMedia();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Instagram - photo stream</title>
    <link href="https://vjs.zencdn.net/4.2/video-js.css" rel="stylesheet">
    <link href="assets/style.css" rel="stylesheet">
    <script src="https://vjs.zencdn.net/4.2/video.js"></script>
</head>
<body>
Example #10
0
 public static function set_instagram_cache()
 {
     $instagram_ids = array(25877499);
     require_once 'InstagramAPIExchange.php';
     require_once 'InstagramException.php';
     $instagram = new Instagram('03159bdd94b14ac1803d1945b6d9c759');
     $instagram->setAccessToken('25877499.1677ed0.bad6959f2be14f9da744d1c0b9f81f26');
     $all_instas = array();
     foreach ($instagram_ids as $id) {
         $all_instas = array_merge($instagram->getUserMedia($id, 5)->data, $all_instas);
     }
     if (!isset($all_instas[0]->created_time)) {
         return false;
     }
     set_transient('instas_time', time(), 60 * 60);
     // store for 1 hour (it gets deleted anyways)
     set_transient('instas', $all_instas, 60 * 60);
     // store for 1 hour (it gets deleted anyways)
     return $all_instas;
 }
Example #11
0
use MetzWeb\Instagram\Instagram;

require_once 'instagram.class.php';

// Initialize class for public requests
$instagram = new Instagram('384463ff33314dc6a8e0e129d28b5e25');
$clientID = $instagram->getApiKey();
$tag = 'kdmarket2016';

if($_GET['code'] == ''){
    LocalRedirect('https://api.instagram.com/oauth/authorize/?client_id=384463ff33314dc6a8e0e129d28b5e25&redirect_uri=http://kdmarket.ru/promo/instagram/get_all_posts.php&response_type=code');
} else {
    $result = array();
    $code = $instagram->getOAuthToken($_GET['code']);
    echo $_GET['code'];
    $token = $instagram->setAccessToken($code->access_token);

    // Receive AJAX request and create call object
    $media = $instagram->getTagMedia($tag, true);
    $maxID = $media->pagination->next_max_id;


    $i = 0;
    foreach ($media->data as $data) {
        if($data->caption->from->username != "kdmarket"){
            $result[$i]['THUMB'] = $data->images->low_resolution->url;
            $result[$i]['IMAGE'] = $data->images->standard_resolution->url;
            $result[$i]['USERNAME'] = $data->caption->from->username;
            $result[$i]['PROFILE_PICTURE'] = $data->caption->from->profile_picture;
            $result[$i]['LIKES'] = $data->likes->count;
            $result[$i]['URL'] = $data->link;
Example #12
0
 public function adminAction()
 {
     /*dump($this->getDoctrine()->getManager());
       dump($this->getDoctrine()->getManager());
       die;*/
     /*$utility = $this->get('wa_back.util');
       echo $utility->slugify('salut ludo');
       dump($utility);
       die;*/
     //Doctrine pour gérer des bbd !=
     //Manager pour gérer des bundles !=
     $em = $this->getDoctrine()->getManager();
     //AFFICHER TOUT LES PRODUITS
     $productAll = $em->getRepository("WaBackBundle:Produit")->findAllPerso();
     //AFFICHER UN PRODUIT
     $product = $em->getRepository("WaBackBundle:Produit")->findPerso(14);
     //AFFICHER LES PRODUITS PAR CATEGORIE
     $productCatHome = $em->getRepository("WaBackBundle:Produit")->pdtWithCatHome(1);
     //AFFICHER LES
     $pdtSansCat = $em->getRepository("WaBackBundle:Produit")->pdtSansCategorie();
     //AFFICHER LE NBR DE PRODUITS PAR CATEGORIE
     $nbrPdtByCat = $em->getRepository("WaBackBundle:Produit")->nbrPdtByCat();
     //AFFICHER LE PRODUIT LE PLUS CHER
     $pdtPrixMax = $em->getRepository("WaBackBundle:Produit")->pdtPrixMax();
     //AFFICHER LES CATEGORIES SANS IMAGES
     $catSansImg = $em->getRepository("WaBackBundle:Categorie")->catSansImg();
     //UTILISER L'APPLI INSTAGRAM
     // Chemin ou on crée le fichier
     $file = __DIR__ . "/../../../../app/cache/cache_instagram.txt";
     $fs = new Filesystem();
     //Timestamp du cache
     $timeCache = time() - 1 * 60;
     //On vérifie qu'on a fait un cache d'1 min avec un dump
     //dump(date ("F d Y H:i:s.", filemtime($file)));
     //dump(date ("F d Y H:i:s.", $timeCache));
     //die(dump($timeCache, filemtime($file)));
     //Si le fichier existe et que le temps d'utilisation de la dernière modif du fichier > timestamp
     //prévu dans le cache
     clearstatcache();
     if ($fs->exists($file) && filemtime($file) > $timeCache) {
         //On récupère le contenu du fichier cacheinsta
         $mesImages = unserialize(file_get_contents($file));
         //die('cache');
     } else {
         //die(dump($this->getParameter('client_id_instagram')));
         $instagram = new Instagram(array('apiKey' => $this->getParameter('client_id_instagram'), 'apiSecret' => $this->getParameter('client_secret_instagram'), 'apiCallback' => $this->getParameter('callback_instagram')));
         //Récupérer le token après le code=
         //die(dump($instagram->getLoginUrl()));
         $instagram->setAccessToken($this->getParameter('token_instagram'));
         //die(dump($instagram->getPopularMedia()));
         $mesImages = $instagram->getUserMedia($this->getParameter('id_instagram'));
         //Mettre les infos dans le fichier
         //Création du fichier
         $fs->touch($file);
         //Mettre les images dans le fichier
         $fs->dumpFile($file, serialize($mesImages));
         //dump(file_get_contents($file));
         //dump($mesImages);
         //die('Utilisation du cache');
     }
     //die(dump($mesImages));
     //Parcourir l'objet et afficher ce qu'on veut
     /*foreach($instagram->getPopularMedia()->data as $media)
       {
           //die(dump($media));
           echo "<img src='".$media->images->thumbnail->url."'>";
           //die;
       }*/
     return $this->render('WaBackBundle:Main:admin.html.twig', ['productAll' => $productAll, 'productDetail' => $product, 'productAccueil' => $productCatHome, 'productSansCat' => $pdtSansCat, 'nbrPdtByCat' => $nbrPdtByCat, 'pdtPrixMax' => $pdtPrixMax, 'catSansimage' => $catSansImg, 'instagram' => $mesImages]);
 }