public function getTimeline($userID = false, $limit = 20)
 {
     $result = array('result' => array());
     $accumulator = $this->debugAccumulatorGroup . '_instagram_timeline';
     eZDebug::accumulatorStart($accumulator, $this->debugAccumulatorGroup, 'timeline');
     $cacheFileHandler = $this->getCacheFileHandler('timeline', array($userID, $limit));
     try {
         if ($this->isCacheExpired($cacheFileHandler)) {
             $API = new Instagram($this->API['key']);
             if ($this->API['token'] !== null) {
                 $API->setAccessToken($this->API['token']);
             }
             $items = array();
             $response = $API->getUserMedia($userID, $limit);
             $items = is_object($response) && isset($response->data) ? $response->data : array();
             foreach ($items as $i => $item) {
                 $items[$i] = self::objectToArray($item);
             }
             $cacheFileHandler->fileStoreContents($cacheFileHandler->filePath, serialize($items));
         } else {
             $items = unserialize($cacheFileHandler->fetchContents());
         }
         eZDebug::accumulatorStop($accumulator);
         $result['result'] = $items;
         return $result;
     } catch (Exception $e) {
         eZDebug::accumulatorStop($accumulator);
         eZDebug::writeError($e->getMessage(), self::$debugMessagesGroup);
         return $result;
     }
 }
 function onNextendInstagram(&$instagram)
 {
     $config = new NextendData();
     $config->loadJson(NextendSmartSliderStorage::get(self::$_group));
     require_once dirname(__FILE__) . "/api/Instagram.php";
     $c = array('client_id' => $config->get('apikey', ''), 'client_secret' => $config->get('apisecret', ''), 'redirect_uri' => '', 'grant_type' => 'authorization_code');
     $instagram = new Instagram($c);
     $instagram->setAccessToken($config->get('token', ''));
 }
Exemple #3
0
function getInstagramData()
{
    // Initialize class for public requests
    // Setup class
    $instagram = new Instagram(array('apiKey' => '73b2123729934af5acbe7d275e382eef', 'apiSecret' => '7d065e9b5bcd47c399139ecb79d2bc92', 'apiCallback' => 'http://misterbrowns.com/'));
    $instagram->setAccessToken('509731687.73b2123.3f895a50426f4fed96adbfb6c1c123cc');
    $data = $instagram->getUserMedia('52746983', 7);
    return $data;
}
 public function feed()
 {
     Phalanx::loadClasses('SocialNetwork');
     $token = SocialNetwork::get_access_token(1, INSTAGRAM);
     $token = json_decode($token);
     $instagram = new Instagram($this->config);
     $instagram->setAccessToken($token->access_token);
     $popular = $instagram->getUserFeed();
     $response = json_decode($popular, true);
     foreach ($response['data'] as $each) {
         echo "<img src='{$each['images']['thumbnail']['url']}'>";
     }
 }
Exemple #5
0
<?php

/*
Example use of aimee.instagram.class.php
*/
require_once 'aimee.instagram.class.php';
// tags to query
$tags = array('englishbulldog', 'igbulldogs_worldwide');
// initiate class
$ig = new Instagram();
// set your access token
$ig->setAccessToken('access_token');
// loop through tags
foreach ($tags as $tag) {
    // searches tag
    $tag = $ig->searchTag($tag);
    // shuffles json data
    shuffle($tag['data']);
    // likes the randomly shuffled tag!
    $ig->likeMedia($tag['data'][0]['id']);
}
// free up some memory
unset($ig);
<?php

require_once 'instagram.class.php';
$instagram = new Instagram(array('apiKey' => '', 'apiSecret' => '', 'apiCallback' => ''));
if ($_COOKIE['ulttoken']) {
    $instagram->setAccessToken($_COOKIE['ulttoken']);
    $user = $instagram->getUser()->data;
    ?>
<div id="content">

<?php 
}
echo "<div class=\"feed-photos\">\n<div class=\"photo-grid \">";
require_once 'con.php';
$check = '';
$code = '';
// Receive OAuth code parameter
if (!isset($_SESSION["check"]) && strlen($_GET["code"]) < 50) {
    $code = $_GET["code"];
    //echo "$code<br>";
    $_SESSION["check"] = $code;
}
$code = $_SESSION["check"];
//echo "$code<br>";
//echo strlen($code);
//echo "$code<br>";
// Check whether the user has granted access
if (true === isset($code) && strlen($code) < 50) {
    //echo "true hit<br>";
    //echo "passed<br>";
    //$data = $instagram->getInstagramPhotos($code);
    //echo $data;
    // Receive OAuth token object
    if (!isset($_SESSION[$token])) {
        //echo "session not set<br>";
        $data = $instagram->getOAuthToken($code);
        $_SESSION[$token] = $data;
        //echo "session = ".$_SESSION[$token];
        $instagram->setAccessToken($data);
    } else {
        $var = $_SESSION[$token];
        //echo "session = ".$_SESSION[$token];
        $instagram->setAccessToken($var);
    }
}
require_once 'Instagram.php';
/**
 * Configuration params, make sure to write exactly the ones
 * instagram provide you at http://instagr.am/developer/
 */
$config = array('client_id' => 'e8d6b06f7550461e897b45b02d84c23e', 'client_secret' => '2357fc69da344800acef2592ef647491', 'grant_type' => 'authorization_code', 'redirect_uri' => 'http://mauriciocuenca.com/qnktwit/');
/**
 * This is how a wrong response looks like
 * array(1) { ["InstagramOAuthToken"]=> string(89) "{"code": 400, "error_type": "OAuthException", "error_message": "No matching code found."}" }
 */
session_start();
if (isset($_SESSION['InstagramAccessToken']) && !empty($_SESSION['InstagramAccessToken'])) {
    header('Location: callback.php');
    die;
}
// Instantiate the API handler object
$instagram = new Instagram($config);
//Setup subscription
if (isset($rs[0]["access_token"])) {
    $instagram->setAccessToken($_SESSION['InstagramAccessToken']);
    if (isset($_GET['list'])) {
        $subscriptions = $instagram->listSubscriptions();
    } else {
        if (isset($_GET['delete'])) {
            $subscriptions = $instagram->deleteSubscription(array("object" => "all"));
        } else {
            $subscriptions = $instagram->createSubscription(array("object" => "tag", "object_id" => "mydowntown", "aspect" => "media", "callback_url" => $config['instagram']['redirect_uri'] . "subscriptions.php"));
        }
    }
    print_r($subscriptions);
}
function search_users()
{
    $options = get_option('si_options');
    $auth = get_option('si_oauth');
    $user = $_POST['user'];
    $config = array('apiKey' => $options['instagram_app_id'], 'apiSecret' => $options['instagram_app_secret'], 'apiCallback' => site_url() . '/wp-admin/admin-ajax.php?action=register_instagram');
    $instagram = new Instagram($config);
    $instagram->setAccessToken($auth);
    $feed = $instagram->searchUser($user, 20);
    foreach ($feed->data as $result) {
        ?>
		<div class="si_sr">
			<div class="si_sr_user_image">
				<img src="<?php 
        echo $result->profile_picture;
        ?>
">
			</div>
			<div class="si_sr_user_info">
				<div class="si_sr_user_name">
					<strong>username: </strong><?php 
        echo $result->username;
        ?>
				</div>
				<div class="si_sr_user_id">
					<strong>user ID: </strong><?php 
        echo $result->id;
        ?>
				</div>
			</div>
		</div>
	<?php 
    }
    exit;
}
Exemple #10
0
 /**
  * @covers Instaphp\Instagram\Instagram::SetAccessToken
  * @todo   Implement testSetAccessToken().
  */
 public function testSetAccessToken()
 {
     // Remove the following lines when you implement this test.
     $this->object->setAccessToken(TEST_ACCESS_TOKEN);
     $this->assertEquals($this->object->getAccessToken(), TEST_ACCESS_TOKEN);
 }
Exemple #11
0
	</div>

	<div class="unit one-of-three">
		<div class="phoneSegment">
			<div class="phoneNumber">
				<?php 
echo get_settings('phone_number');
?>
			</div>
			<a href="https://hbahairdesign.mylocalsalon.com/onlinebooking/" class="bookOnline">Book Online</a>
		</div>

		<div class="instagramSection">
			<?php 
$instagram = new Instagram(array('apiKey' => get_option('HBA_INSTA_CLIENT_ID'), 'apiSecret' => get_option('HBA_INSTA_CLIENT_SECRET'), 'apiCallback' => site_url() . '/wp-admin/options-general.php?page=themeOptions.php'));
$instagram->setAccessToken(get_settings('HBA_INSTA_AUTH'));
$user = $instagram->getUser();
$userLike = $instagram->getUserMedia();
?>

			<a href="http://instagram.com/<?php 
echo $user->data->username;
?>
" class="instagramLink">@hbahair</a>
			<a href="http://instagram.com/<?php 
echo $user->data->username;
?>
" class="instagramUsLink">Instagram Us!</a>

			<div class="instagramPicture">
				<img src="<?php 
 function _createInstagram()
 {
     $options = get_option('si_options');
     $auth = get_option('si_oauth');
     $config = array('apiKey' => $options['instagram_app_id'], 'apiSecret' => $options['instagram_app_secret'], 'apiCallback' => site_url() . '/wp-admin/admin-ajax.php?action=register_instagram');
     $instagram = new Instagram($config);
     $instagram->setAccessToken($auth);
     return $instagram;
 }
Exemple #13
0
<?php

require 'instagram.class.php';
$instagram = new Instagram(array('apiKey' => '563239a4c8214a85b9153d00c1a2a00f', 'apiSecret' => '4f6256459c5c417dbe48b8609e1cc123', 'apiCallback' => 'http://localhost/ws/Works/instagram/phpInsta/'));
$token = 'USER_ACCESS_TOKEN';
$instagram->setAccessToken($token);
$id = 'MEDIA_ID';
$result = $instagram->likeMedia($id);
if ($result->meta->code === 200) {
    echo 'Success! The image was added to your likes.';
} else {
    echo 'Something went wrong :(';
}
Exemple #14
0
 /**
  * @return Instacian configurada de la API Instagram
  */
 function getBgramAPIInstance($config)
 {
     // Inicializamos la API
     $instagram = new Instagram($config);
     if ($config['is_admin']) {
         $instagram->setAccessToken(BlockGramPlugin::getBgramAccessToken());
     }
     return $instagram;
 }
Exemple #15
0
$scopes = array('basic', 'likes', 'comments', 'relationships');
?>
<a href="<?php 
echo $ig->getLoginUrl($scopes);
?>
">Login</a>
<?php 
$users = $ig->searchUser('maanmughal87', 1);
echo '<pre>users:';
print_r($users);
$code = $_GET['code'];
$data = $ig->getOAuthToken($code);
echo '<pre>';
print_r($data);
// set user access token
$ig->setAccessToken($data);
// get all user likes
$likes = $ig->getUserLikes();
// take a look at the API response
echo '<pre>likes';
print_r($likes);
echo '<pre>';
// get all user likes
$follows = $ig->getUserFollows();
// take a look at the API response
echo '<pre>follows';
print_r($follows);
echo '<pre>';
$followship = $ig->modifyRelationship('follow', 2057410915);
echo '<br />followship';
print_r($followship);