Skip to content

Instantly share code, notes, and snippets.

@blbwd

blbwd/template.php

Created Sep 10, 2015
Embed
What would you like to do?
instagram image feed on your website
<div class="instram-container">
<?php
$user_id = "xxxxxxxxxx"; //userid
$num_to_display = "8"; //instagram limits to max 20, but you can do less for your layout.
$access_token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"; // access token
?>
<div class="instagram-block"></div>
<script type="text/javascript">
$(function() {
$.ajax({
type: "GET",
dataType: "jsonp",
cache: false,
url: "https://api.instagram.com/v1/users/<?=$user_id?>/media/recent/?access_token=<?=$access_token?>",
success: function(data) {
for (var i = 0; i < <?=$num_to_display?>; i++) {
$(".instagram-block").append("<ul><li><a target='_blank' href='" + data.data[i].link +"'><img height='227' width='242' class='instagram-image' src='" + data.data[i].images.low_resolution.url +"' /></a></li></ul>");}
}
});});
</script>
<div class="clear"></div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment