$accesstoken =’RT%^jghffhnbfu787kh’;

$slideritem =’3’;

$url = “https://api.instagram.com/v1/users/”.$userid.”/media/recent?s=150&access_token=”.$accesstoken.”&count=”.$slideritem;

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$json = curl_exec($ch);

curl_close($ch);

$result = json_decode($json);

if($result==””) { ?>

<h3 class=”sc_title sc_title_center sc_lines inner-hed” style=”color:red;”>

<?php echo (“Invalid User id.”);?>

</h3>

<?php }

elseif(empty($result->data)){  ?>

<h3 class=”sc_title sc_title_center sc_lines inner-hed” style=”color:red;”>

<?php echo (“Something is wrong please check your Access Token.”);

?>

</h3>

<?php   }

else{

$width_height=”500″     ;

foreach ($result->data as $post) {

$data[‘images’][] = array(

‘title’ => ($post->caption)? (($post->caption->text) ? $post->caption->text :”) : ”,

‘link’  => $post->link,

‘image’ => str_replace(‘s320x320′,’s’.$width_height,$post->images->low_resolution->url)

);

}  ?>

<div class=”container”>

<h3 class=”sc_title sc_title_center sc_lines inner-hed”>

<span><?php  echo $titles; ?></span>

</h3>

<div class=”instagraminage”>

<ul class=”bxslider”>

<?php  foreach ($data[‘images’] as $image) {

?>

<li class=”item”>

<a href=”<?php echo $image[‘link’]; ?>” target=”_blank”> <img src=”<?php echo $image[‘image’]; ?>” alt=”<?php echo $image[‘title’]; ?>” class=”img-responsive” /> </a>

</li>

<?php } ?></ul>

</div>

</div>

Your Answer
Sign In
Enter email and password to comment or answer
Not the answer you are looking for? Browse other questions tagged or ask your own question.