Thursday, January 5, 2017

How to get multiple Instagram users using curl in php



If you want to show Instagram user listing in your website using Instagram api.

<?php

       $accessToken = "enter your access token here";
$userid = array(0123456789,0123456789,0123456789,0123456789);

foreach($userid as $users):
    $url = "https://api.instagram.com/v1/users/".$users."?access_token=".$accessToken;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
$result = curl_exec($ch);
curl_close($ch);
    $result = json_decode($result);
?>
  <div class="row-col-3">
  <a href="#">
  <div class="feature-shoutout-col">
  <div class="feature-image"><img src="<?php echo $result->data->profile_picture;?>" alt=""></div>
  <div class="feature-info">
  <p class="feature-title"><?php echo $result->data->counts->followed_by;?> followers</p>
  <p class="feature-username">@<?php echo $result->data->username;?></p>
  <p class="feature-price">$300</p>
  </div>
  </div>
  </a>
  </div>
 <?php endforeach;?> 

0 comments:

Post a Comment