
­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
<?php

if ( ! function_exists( 'presso_get_instagram_feed' ) ) {
	function presso_get_instagram_feed( $count=8 ) {
		$instagram_access_token = presso_get_theme_option( 'instagram_access_token' );

		if ( empty( $instagram_access_token ) ) return false;

		$json = presso_remote_get( 'https://api.instagram.com/v1/users/self/media/recent/?access_token='.urlencode( $instagram_access_token ) );
		$json = json_decode( $json );

		if ( empty( $json ) ) { return false; }

		$username = $json->data[0]->user->username;
		$images = array();

		foreach( $json->data as $i => $image ) {
			if ( $i >= $count ) break;

			$images[] = array(
				'link' => $image->link,
				'src' => $image->images->low_resolution->url,
			);
		}

		return array(
			'username' => $username,
			'images' => $images
		);
	}
}