/** * Execute the job. * * @return void */ public function handle() { $instagram = new Instagram(array('apiKey' => config('instagram.id'), 'apiSecret' => config('instagram.secret'), 'apiCallback' => 'http://instagram.app')); $account = InstagramAccount::find($this->id); $accountMedia = []; $user = $instagram->getUser($account['instagram_object_id']); if ($user->meta->code == 200) { $mediaCount = $user->data->counts->media; if ($mediaCount != 0) { $media = $instagram->getUserMedia($account['instagram_object_id'], 32); while (!is_null($media)) { foreach ($media->data as $data) { if ($data->type == 'video') { continue; } $accountMedia[] = new InstagramMedia(['instagram_object_id' => $data->id, 'photo_url' => $data->link, 'photo_caption' => is_object($data->caption) ? $data->caption->text : null, 'likes_count' => $data->likes->count, 'comments_count' => $data->comments->count]); } $media = $instagram->pagination($media, 32); } } else { $account->status = InstagramAccount::GRABBER_COMPLETED; $account->save(); } } DB::transaction(function () use($account, $accountMedia) { $account->InstagramMedia()->saveMany($accountMedia); $account->status = InstagramAccount::GRABBER_COMPLETED; $account->save(); }); }
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]; }
static function add_instagram_photo() { $language = $_POST['language']; $code = $_POST['embedCode']; $dirID = $_POST['dirID']; $instagram = new Instagram(array('apiKey' => 'be70ed08fc66446ba46b4797870a4c62', 'apiSecret' => '3486b765962d40aa8037c4cc0b37ff8c', 'apiCallback' => 'YOUR_APP_CALLBACK')); $api = file_get_contents("http://api.instagram.com/oembed?url={$code}"); $apiObj = json_decode($api, true); $media_id = $apiObj['media_id']; $data = $instagram->getMedia($media_id); // MainController::printArray($data); if ($data->data->type == "video") { $url = $data->data->videos->standard_resolution->url; $height = $data->data->videos->standard_resolution->height; $width = $data->data->videos->standard_resolution->width; $width = $data->data->videos->standard_resolution->width; } else { if ($data->data->type == "image") { $url = $data->data->images->standard_resolution->url; $width = $data->data->images->standard_resolution->width; $height = $data->data->images->standard_resolution->height; } } $date = date('d.m.Y', $data->data->created_time); $caption = $data->data->caption->text; $type = $data->data->type; Dispatcher::$mysqli->query("insert into instagram (code, direction_id, type, width, height, caption, created_time) " . "values ('{$url}', '{$dirID}', '{$type}', '{$width}', '{$height}', '{$caption}', '{$date}')"); }
function get_user_id(Instagram $instagram) { $userData = $instagram->getUser(); if ($userData) { return $userData->data->id; } return false; }
public function searchMediasWithTag($tag, $number = null) { if ($number) { $this->numberElements = $number; } $instagram = new Instagram('85670c857e314427a9fc5aac80962646'); $medias = $instagram->getTagMedia($tag, $this->numberElements); dump($medias); return self::insertMultiple($medias->data); }
/** * @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; }
/** * Execute the job. * * @return void */ public function handle() { $instagram = new Instagram(array('apiKey' => config('instagram.id'), 'apiSecret' => config('instagram.secret'), 'apiCallback' => 'http://instagram.app')); $account = InstagramAccount::find($this->id); $account->status = InstagramAccount::GRABBER_NOT_COMPLETED; $account->save(); $accountMedia = array_combine($account->instagramMedia->lists('instagram_object_id')->toArray(), $account->instagramMedia->all()); $user = $instagram->getUser($account['instagram_object_id']); if ($user->meta->code == 200) { $mediaCount = $user->data->counts->media; if ($mediaCount != 0) { $media = $instagram->getUserMedia($account['instagram_object_id'], 32); while (!is_null($media)) { foreach ($media->data as $data) { if ($data->type == 'video') { continue; } if ($this->mode == 'WITH_ADVANCED' && isset($accountMedia[$data->id])) { $accountMedia[$data->id]->instagramMediaLike()->save(new InstagramMediaLike(['count' => $data->likes->count - $accountMedia[$data->id]->likes_count])); $comments = $instagram->getMediaComments($data->id); if (!empty($comments->data)) { foreach ($comments->data as $comment) { $accountMedia[$data->id]->instagramMediaComment()->updateOrCreate(['instagram_object_id' => $comment->id], ['instagram_object_id' => $comment->id, 'created_at' => Carbon::createFromTimestamp($comment->created_time)]); } } } if (isset($accountMedia[$data->id])) { // update $accountMedia[$data->id]->photo_caption = is_object($data->caption) ? $data->caption->text : null; $accountMedia[$data->id]->likes_count = $data->likes->count; $accountMedia[$data->id]->comments_count = $data->comments->count; } else { // insert $accountMedia[] = new InstagramMedia(['instagram_object_id' => $data->id, 'photo_url' => $data->link, 'photo_caption' => is_object($data->caption) ? $data->caption->text : null, 'likes_count' => $data->likes->count, 'comments_count' => $data->comments->count]); } } $media = $instagram->pagination($media, 32); } } else { $account->status = InstagramAccount::GRABBER_COMPLETED; $account->save(); } } DB::transaction(function () use($account, $accountMedia) { $account->InstagramMedia()->saveMany($accountMedia); $account->status = InstagramAccount::GRABBER_COMPLETED; $account->save(); }); }
/** * validateMedia it controls the input is numeric * and connect with Instagram API for location data * * @param int $media_id * @return array response * array response['location'] || response['error'] * int response['status'] **/ public function validateMedia($media_id) { if (!empty((int) $media_id)) { $instagram = $this->instagram->getMedia($media_id); if (!empty($instagram)) { if (empty($instagram->meta->error_type)) { $response = array('location' => $instagram->data->location, 'status' => 200); } else { $response = array('error' => array('error' => $instagram->meta->error_type, 'message' => $instagram->meta->error_message), 'status' => 409); } } else { $response = array('error' => array('error' => self::DATA_NULL, 'message' => self::DATA_NULL_MESSAGE), 'status' => 409); } } else { $response = array('error' => array('error' => self::ERROR_API, 'message' => self::ERROR_API_MESSAGE), 'status' => 409); } return $response; }
public function searchInstagramWithTag($tag, $number = null, $accessToken = null) { if ($number) { $this->numberElements = $number; } if ($accessToken) { $_accesToken = $accessToken; } else { $_accesToken = $this->access_token; } $instagram = new Instagram($_accesToken); $medias = $instagram->getTagMedia($tag, $number); if (self::_checkErrorsConnections($medias)) { return self::_checkErrorsConnections($medias); } if (isset($medias->pagination->next_url)) { $data['next_url'] = $medias->pagination->next_url; } $data['medias'] = self::insertMultiple($medias->data); return $data; }
/** * Created by PhpStorm. * User: Alumne * Date: 08/02/2016 * Time: 15:30 */ require 'instagram/vendor/cosenary/instagram/src/Instagram.php'; use MetzWeb\Instagram\Instagram; session_start(); if (isset($_SESSION['access_token'])) { // user authentication -> redirect to media header('Location: success.php'); } // initialize class $instagram = new Instagram(array('apiKey' => '41f65a5c684048bca797dbf0775c9ec7', 'apiSecret' => '95647e6ef2a445ff92e8b27c82bf8da6', 'apiCallback' => 'http://localhost/instagram_toOld.php')); // create login URL $loginUrl = $instagram->getLoginUrl(array('basic', 'likes', 'relationships')); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Instagram - OAuth Login</title> <link rel="stylesheet" type="text/css" href="assets/style.css"> <style> .login { display: block; font-size: 20px; font-weight: bold;
<?php require 'Instagram-PHP-API/Instagram.php'; require 'functions.php'; use MetzWeb\Instagram\Instagram; // Custom User Information - TWITTER $instagramScreenName = 'grayson_erhard'; $instagramUserID = 504804161; $apiKey = "7d5fc656628a412d91ced88b093d33bb"; $apiSecret = "d0875059cefe453091a875ede6edd45f"; $apiCallback = "http://scavenger-app.com/scavenger/platforms/instagram/test.php"; $instagram = new Instagram(array('apiKey' => $apiKey, 'apiSecret' => $apiSecret, 'apiCallback' => $apiCallback)); // grab OAuth callback code $code = $_GET['code']; $data = $instagram->getOAuthToken($code); print_r($data); // set user access token $instagram->setAccessToken($data); echo "<a href='{$instagram->getLoginUrl()}'>Login with Instagram</a>"; echo "<br>";
<?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()); }
<?php session_start(); require '../api/instagram.php'; use MetzWeb\Instagram\Instagram; /* 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)); // Receive OAuth code parameter $code = $_GET['code']; // Check whether the user has granted access if (true === isset($code)) { // Receive OAuth token object $data = $instagram->getOAuthToken($code); session_start(); // Storing instagram user data into session $_SESSION['userdetails'] = $data; $user = $data->user->username; $fullname = $data->user->full_name; $xid = $data->user->id; $token = $data->access_token; sleep(10); header('Location: http://dm2dev.com/smg/#/almost-done'); } ?>
// update last activity time stamp require '../api/instagram.php'; use MetzWeb\Instagram\Instagram; require_once '../twitter/twitteroauth/twitteroauth.php'; require_once '../twitter/config.php'; /* DATABASE */ $servername = "internal-db.s187806.gridserver.com"; $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) {
<?php 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'])) {
<?php require "vendor/cosenary/instagram/src/Instagram.php"; require "radar.php"; use MetzWeb\Instagram\Instagram; ini_set("max_execution_time", 123456); $instagram = new Instagram("af797da93a514a9381d6862490944f45"); $tag = "video"; // Set number of photos to show $limit = 10; $result = $instagram->getTagMedia($tag, $limit); // Users $users = get_users_post_like($result->data); echo "Users (" . sizeof($users) . ")<br>"; echo "Username Posts Likes<br>"; foreach ($users as $user) { echo $user["user_id"] . "--" . $user["username"] . "--" . $user["post_num"] . "--" . $user["like_num"] . "<br>"; } echo "<br><br>Top Users<br>"; // Search user with most posts and likes $top_users = get_top_users($instagram, $users); $max_post_idx = $top_users["max_post_idx"]; $max_like_idx = $top_users["max_like_idx"]; $max_post = $users[$max_post_idx]["post_num"]; $max_like = $users[$max_like_idx]["like_num"]; $max_post_username = $users[$max_post_idx]["username"]; $max_like_username = $users[$max_like_idx]["username"]; echo "Most posts: " . $max_post . " posts by " . $max_post_username . "<br>"; echo "Most likes: " . $max_like . " likes by " . $max_like_username . "<br><br><br>"; // Activities Volume $image_type_count = 0;
<?php require 'assets/lib/instagram/insta.php'; use MetzWeb\Instagram\Instagram; $QR = 'No query'; $result = array(); $image = array(); $NumberOfInstaPosts = 19; $instagram = new Instagram(array('apiKey' => 'API KEY', 'apiSecret' => 'API SECRET', 'apiCallback' => 'http://www.pharzan.com/insta_success_callback.php')); if (isset($_GET['type'])) { if ($_GET['type'] == 'selfie') { $result[0] = $instagram->getTagMedia('selfie'); for ($i = 0; $i <= $NumberOfInstaPosts - 1; $i++) { $image['links'][$i] = $result[0]->data[$i]->images->standard_resolution->url; $image['userinfo'][$i] = $result[0]->data[$i]->caption; } //print_r($image); $QR = $image; } } echo json_encode($QR);
<?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); } }
</style> </head> <body> <h1>Instagram Hashtag Explorer</h1> <?php ini_set('default_charset', 'UTF-8'); ini_set('memory_limit', '512M'); ini_set('max_execution_time', 3000); require "conf.php"; require "php-api/src/Instagram.php"; use MetzWeb\Instagram\Instagram; // initialize class $instagram = new Instagram(array('apiKey' => $apiKey, 'apiSecret' => $apiSecret, 'apiCallback' => $apiCallback)); // receive OAuth code parameter $code = $_GET['code']; // check GET variables $getuserinfo = $_GET["getuserinfo"] == "on" ? true : false; $showimages = $_GET["showimages"] == "off" ? false : $_GET["showimages"]; $query = urlencode(preg_replace("/#/", "", trim($_GET["tag"]))); $iterations = trim($_GET["iterations"]); $mode = $_GET["mode"]; // check whether the user has granted access if (isset($code)) { $data = $instagram->getOAuthToken($code); $username = $data->user->username; $instagram->setAccessToken($data); if (isset($data->error_message)) { echo 'This tool currently needs to reauthenticate every call, please go back to <a href="https://tools.digitalmethods.net/netvizz/instagram/">https://tools.digitalmethods.net/netvizz/instagram/</a> to long in again.';
<?php /** * Created by PhpStorm. * User: Alumne * Date: 08/02/2016 * Time: 15:33 */ require 'instagram/vendor/cosenary/instagram/src/Instagram.php'; use MetzWeb\Instagram\Instagram; // initialize class $instagram = new Instagram(array('apiKey' => '41f65a5c684048bca797dbf0775c9ec7', 'apiSecret' => '95647e6ef2a445ff92e8b27c82bf8da6', 'apiCallback' => 'http://localhost/instagram_toOld.php')); session_start(); $token = false; if (isset($_SESSION['access_token'])) { // user authenticated -> receive and set token $token = $_SESSION['access_token']; } else { // receive OAuth code parameter $code = $_GET['code']; // authentication in progress? if (isset($code)) { // receive and store OAuth token $data = $instagram->getOAuthToken($code); $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']; }
# Instagram is an online mobile photo-sharing, # video-sharing and social networking service that # enables its users to take pictures and videos, # and share them on a variety of social networking platforms. # # This example uses a third-party PHP library to authenticate a user # and to output the most popular media. # # Please see these for more information: # # http://instagram.com/developer/ # https://github.com/cosenary/Instagram-PHP-API require_once 'Instagram.php'; use MetzWeb\Instagram\Instagram; $instagram = new Instagram(array('apiKey' => 'YOUR_APP_KEY', 'apiSecret' => 'YOUR_APP_SECRET', 'apiCallback' => 'YOUR_APP_CALLBACK')); $result = $instagram->getPopularMedia(); foreach ($result->data as $media) { $content = "<li>"; // output media if ($media->type === 'video') { // video $poster = $media->images->low_resolution->url; $source = $media->videos->standard_resolution->url; $content .= '<video width="250" height="250" poster="' . $poster . '" data-setup="{"controls":true, "preload": "auto"}"> <source src="' . $source . '" type="video/mp4" /> </video>'; } else { // image $image = $media->images->low_resolution->url;
<?php /** * Instagram PHP API * * @link https://github.com/cosenary/Instagram-PHP-API * @author Christian Metz * @since 01.10.2013 */ require 'src/Instagram.php'; use MetzWeb\Instagram\Instagram; require '../initialize.php'; // initialize class $instagram = new Instagram(array('apiKey' => $apikey, 'apiSecret' => $apisecret, 'apiCallback' => $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->getUserFeed(); $loginUrl = $instagram->getLoginUrl(); } else { // check whether an error occurred if (isset($_GET['error'])) { echo 'An error occurred: ' . $_GET['error_description']; }
<?php require 'Instagram-PHP-API/Instagram.php'; use MetzWeb\Instagram\Instagram; $apiKey = "7d5fc656628a412d91ced88b093d33bb"; $apiSecret = "d0875059cefe453091a875ede6edd45f"; $apiCallback = "http://scavenger-app.com/scavenger/platforms/instagram/test.php"; $instagram = new Instagram(array('apiKey' => $apiKey, 'apiSecret' => $apiSecret, 'apiCallback' => $apiCallback)); echo "<a href='{$instagram->getLoginUrl()}'>Login with Instagram</a>";
<?php // vi skal ikke bruger header, men WP's funktionsbibliotek define('WP_USE_THEMES', false); // Vores retur encodes til json, så det er nemt at bruge i javascript. header('Cache-Control: no-cache, must-revalidate'); header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); header('Content-Type: application/json'); // Hent wp-load, så vi får mulighed for at bruge wordpress' funktionsarkiv require '../../../../../wp-load.php'; // Klargør response array til senere json_encode(); $response = array(); $tag = wp_strip_all_tags($_POST['tag']); require_once 'instagram.class.php'; use MetzWeb\Instagram\Instagram; $instagram = new Instagram(array('apiKey' => '122901c27b0d4313bbc5c7053250ebe4', 'apiSecret' => '34b46c39caf44729a79c332f79f719f5', 'apiCallback' => 'http://smamo.dk/rd')); $insta_obj = $instagram->getTagMedia($tag, 16); $i = 0; foreach ($insta_obj->data as $instance) { $i++; /* Vis med billede eller større */ // Med billede $image_url = $instance->images->standard_resolution->url; if ($image_url) { $response[$i] = $image_url; } } echo json_encode($response);
<?php 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')); // create login URL $loginUrl = $instagram->getLoginUrl(); ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Instagram - OAuth Login</title> <link rel="stylesheet" type="text/css" href="assets/style.css"> <style> .login { display: block; font-size: 20px; font-weight: bold; margin-top: 50px; } </style> </head> <body> <div class="container"> <header class="clearfix"> <h1>Instagram <span>display your photo stream</span></h1> </header> <div class="main">
<?php /***************************************** * Saves user access toekn to database /****************************************/ 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)); // Check whether the user has granted access if (isset($_GET['code'])) { // Receive OAuth token object $data = $instagram->getOAuthToken($_GET['code']); // Save user access token to database $options['token'] = $data; update_option('hipstr_options', $options); } }
function getInstaUserId($username, Instagram $instagram) { $user_info = $instagram->searchUser($username, 1); $user_info = $user_info->data; return $user_info[0]->id; }
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]); }
<?php /** * Instagram PHP API * * @link https://github.com/cosenary/Instagram-PHP-API * @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']; } } ?>
<?php ini_set('display_errors', true); error_reporting(E_ALL); use MetzWeb\Instagram\Instagram; include '/var/www/Instagram-PHP-API/src/Instagram.php'; include '/var/www/Instagram-PHP-API/src/InstagramException.php'; $instagram = new Instagram(array('apiKey' => getenv('CLIENT_ID'), 'apiSecret' => getenv('CLIENT_SECRET'), 'apiCallback' => 'http://www.amberandbrice.com/wedding_imager/success.php')); /*$instagram = new Instagram(getenv('CLIENT_ID')); $result = $instagram->getPopularMedia();*/ $code = $_GET['code']; // check whether the user has granted access if (isset($code)) { // receive OAuth token object $data = $instagram->getOAuthToken($code); //$username = $data->user->username; // store user access token $instagram->setAccessToken($data); // now you have access to all authenticated user methods $result = $instagram->getUserMedia(); $tagresult = $instagram->getTagMedia('louisiana'); } else { // check whether an error occurred if (isset($_GET['error'])) { echo 'An error occurred: ' . $_GET['error_description']; } } var_dump($result); var_dump($tagresult);