<?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">
$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']; } //print_r($insta->getUserLikes(1)); } ?> <!doctype html> <html> <body> <img src="instagram.ico" height="42" width="42" > <a src="instagram.ico" href = "<?php echo $insta->getLoginUrl(); ?> ">Login1</a> </body> </html>
<?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>";
} ?> </span> <span id="igswap" class="social-btn <?php if ($isfollowinginsta == 'follows') { echo 'swap'; } ?> "> <center onclick="addClass('igswap', 'swap')" class="ig-first"><a class="button-extra igbtn" target="_blank" href="https://instagram.com/Sarahmgellar" style="display:inherit;"><i class="flaticon-instagram12"></i><span>FOLLOW US</span><br>For Another Entry</h4></a></center> <div class="ig-follow" style="display: none"> <?php if ($isfollowinginsta == 'follows') { echo '<center class="button-extra igbtn following"><i class="flaticon-instagram12"></i><span>FOLLOW US</span><br>For Another Entry</h4><span class="check"><i class="flaticon-verify5"></i></span></center>'; } else { $loginUrl = $instagram->getLoginUrl(array('basic', 'relationships')); ?> <center class="button-extra igbtn following"><i class="flaticon-instagram12"></i><span>FOLLOW US</span><br>For Another Entry</h4><span class="check"><i class=""></i></span> <div id="igbig">Confirm your extra entry by clicking <a href="<?php echo $loginUrl; ?> " style="display:inline;">here!</a></div> </center> <?php } ?> </div> </span>
/** * Get the authentication url to add an user. * * @return string */ public function getAuthUrl() { return $this->_instagram->getLoginUrl(['basic', 'public_content']); }
$view = $app->view(); $view->parserOptions = array('debug' => true, 'cache' => dirname(__FILE__) . '/cache'); $app->get('/login', function () use($app, $client) { $data = array(); $login_url = ''; if ($app->request->get('code')) { $code = $app->request->get('code'); $response = $client->post('https://api.instagram.com/oauth/access_token', array('body' => array('client_id' => CLIENT_ID, 'client_secret' => CLIENT_SECRET, 'grant_type' => 'authorization_code', 'redirect_uri' => REDIRECT_URL, 'code' => $code))); $data = $response->json(); } else { $login_url = "https://api.instagram.com/oauth/authorize?client_id={$client_id}&redirect_uri={$redirect_url}&scope=basic&response_type=code"; } $app->render('home.php', array('data' => $data, 'login_url' => $login_url)); }); $app->get('/login2', function () use($app, $instagram) { $login_url = $instagram->getLoginUrl(array('basic', 'likes')); if (!empty($_GET['code'])) { $code = $_GET['code']; $data = $instagram->getOAuthToken($code); //get access token using the authorization code $instagram->setAccessToken($data); $access_token = $instagram->getAccessToken(); //do anything you want with the access token } else { $app->render('login.php', array('login_url' => $login_url)); } }); $app->get('/user', function () use($app, $instagram, $user_id) { $results = $instagram->getUser($user_id); $app->render('user.php', array('user' => $results->data)); });
<?php use MetzWeb\Instagram\Instagram; include '/var/www/Instagram-PHP-API/src/Instagram.php'; include '/var/www/Instagram-PHP-API/src/InstagramException.php'; ini_set('display_errors', true); error_reporting(E_ALL); $instagram = new Instagram(array('apiKey' => getenv('CLIENT_ID'), 'apiSecret' => getenv('CLIENT_SECRET'), 'apiCallback' => 'http://www.amberandbrice.com/wedding_imager/success.php')); $scopes = array('basic', 'relationships', 'likes', 'comments', 'public_content'); echo "<a href='" . $instagram->getLoginUrl($scopes) . "'>Login with Instagram</a>";
curl_close($curl_connection); print_r($data ); } catch(Exception $e) { echo 'fail'; return $e->getMessage(); } } */ ?> <?php use MetzWeb\Instagram\Instagram; $instagram = new Instagram(array('apiKey' => '41ef4cd023ca47c79ef0f5cb7505033d', 'apiSecret' => 'dc6ec29ac5ce4b7e88e98dc89a7517db', 'apiCallback' => 'http://www.3dcrestwhite.ru/automation/')); $instagram->getLoginUrl(array('basic', 'likes')); echo "<a href='{$instagram->getLoginUrl()}'>Login with Instagram</a>" . '<br>'; // grab OAuth callback code $code = get_query_var('code'); $data = $instagram->getOAuthToken($code); echo 'Your username is: ' . $data->user->username . '<br>'; //print_r($data) ; $token = $data->access_token; echo 'TOKEN: ' . $token . '<br>'; $instagram->setAccessToken($token); $likes = $instagram->getUserLikes(); // take a look at the API response echo '<pre>'; print_r($likes); echo '<pre>'; $followers = $instagram->getUserFollower('vaha_13', 10);