Skip to content

Instantly share code, notes, and snippets.

@cosenary
Last active May 26, 2017 07:17
Show Gist options
  • Save cosenary/c94189237038769e026d to your computer and use it in GitHub Desktop.
Save cosenary/c94189237038769e026d to your computer and use it in GitHub Desktop.
Load user's public Instagram media
<?php
/**
* Instagram PHP API
* Example for using the getUserMedia() method
*
* @link https://github.com/cosenary/Instagram-PHP-API
* @author Christian Metz
* @since 4.04.2014
*/
require 'Instagram.php';
use MetzWeb\Instagram\Instagram;
// initialize class
$instagram = new Instagram('YOUR_APP_KEY');
// user ID (find your ID: http://otzberg.net/iguserid)
$userID = 347792643;
// get the most recent public media published by the user
$media = $instagram->getUserMedia($userID, 8);
// display the most recent public media published by the user
foreach ($media->data as $entry) {
echo "<img src=\"{$entry->images->thumbnail->url}\">";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment