Get Images from your Instagram Account


In this tutorial I will show you how to get images from your Instagram account. To get images from Instagram we need Access Token and Instagram user ID. Please read previous posts Get Instagram Access Token Using Client-Side Authentication and How to get Self Instagram User ID to get Access Token and Instagram user ID.

Get images from your Instagram Account

Now we will use file_get_contents method to get remote content.


$accessToken = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";  
$userid = "**************";

$result = file_get_contents("https://api.instagram.com/v1/users/{$userid}/media/recent/?access_token={$accessToken}");
$images = json_decode($result);

foreach($images->data as $image){
	echo '<img width="'.$image->images->thumbnail->width.'" height="'.$image->images->thumbnail->height.'" src="'.$image->images->thumbnail->url.'">';
}

Hope this tutorial will help you to get images from your Instagram Account.