<?php
// use this instagram access token generator http://instagram.pixelunion.net/
//https://www.tradexpoindonesia.com/?code=16b401baeee94e36b46adb522c0baaef
$access_token="5586856834.1677ed0.2acfd998c74f46c484853ce51a253996";
$photo_count=9;
     
$json_link="https://api.instagram.com/v1/users/self/media/recent/?";
$json_link.="access_token={$access_token}&count={$photo_count}";

$json = file_get_contents($json_link);
$obj = json_decode($json, true, 512, JSON_BIGINT_AS_STRING);

if (isset($obj['data'])) {
	foreach ($obj['data'] as $post) {
		$pic_text=$post['caption']['text'];
		$pic_link=$post['link'];
		$pic_like_count=$post['likes']['count'];
		$pic_comment_count=$post['comments']['count'];
		$pic_src=str_replace("http://", "https://", $post['images']['standard_resolution']['url']);
		$pic_created_time=date("F j, Y", $post['caption']['created_time']);
		$pic_created_time=date("F j, Y", strtotime($pic_created_time . " +1 days"));
		echo '<div class="col l-col6 m-col6 s-col6">'; 
			echo "<a href='{$pic_link}' target='_blank'>";
				echo "<img class='img-fluid' src='{$pic_src}' alt='{$pic_text}'>";
			echo "</a>";
			echo "<p>";
				echo "<p>";
					echo "<div style='color:#888;'>";
						echo "<div>Like: ".$pic_like_count."</div>";
						echo "<di>Comment: ".$pic_comment_count."</div>";
						echo "<a href='{$pic_link}' target='_blank'>{$pic_created_time}</a>";
					echo "</div>";
				echo "</p>";
				echo "<p>{$pic_text}</p>";
			echo "</p>";
		echo '</div>';	
	}

}
?> 


