<?php error_reporting(E_ALL); ini_set('display_errors', '1'); require_once __DIR__ . '/Instagram/Instagram.php'; require_once __DIR__ . '/Instagram/Exception/InstagramException.php'; use Instagram\Instagram; /* create Instagram class with just client id. These will be unauthed requests. */ $client_id = 'YOUR CLIENT ID'; $instagram = new Instagram($client_id); $res = $instagram->get('/media/popular'); // User endpoints. $callParams = array('q' => 'dennis'); $res = $instagram->get('/users/search', $callParams); $res = $instagram->get('/users/3'); // This will fail because it needs an access token. $callParams = array('count' => 10); //$res = $instagram->get('/users/self/feed', $callParams); $callParams = array('count' => 10); $res = $instagram->get('/users/3/media/recent', $callParams); var_dump($res);
$code = !empty($_GET['code']) ? $_GET['code'] : ''; $client_id = 'YOUR CLIENT ID'; $client_secret = 'YOUR SECRET'; $redirect = 'http://localhost:8081/InstagramPhpApi/demo_auth.php'; $instagram = new Instagram($client_id, $client_secret, $redirect); ?> <a href="<?php echo $instagram->getAuthUrl(); ?> ">Authorize</a> <?php if ($code != '') { $instagram->getAccessToken($code); $user = $instagram->getUser(); $res = $instagram->get('/media/popular'); $res = $instagram->get('/users/self/media/liked'); var_dump($res); } if ($code != '') { ?> <p>User: <?php echo $user->username; ?> </p> <p><img src="<?php echo $user->profile_picture; ?> " /></p> <?php }