Skip to content

Instantly share code, notes, and snippets.

@gsampaio
Created January 8, 2012 15:59
Show Gist options
  • Save gsampaio/1578805 to your computer and use it in GitHub Desktop.
Save gsampaio/1578805 to your computer and use it in GitHub Desktop.
Instagram Recent Feed Javascript
/**
* A simple javascript script to get the lastest images from your instagram account.
* Require an app to acess instagram api in order to get the access_token and user_id
* Require jquery for the ajax and dom manipulation
*/
var settings = {
user : 'ENTER_YOUR_USER_ID_HERE',
access_token : 'ENTER_YOUR_USER_ACCESS_TOKEN_HERE'
};
var url = 'https://api.instagram.com/v1/users/'+settings.user+'/media/recent/?access_token='+settings.access_token;
$.ajax({
type: "GET",
url: url,
dataType: "jsonp",
success: function(data) {
json = data;
var images = [];
$.each(json.data, function(id, img){
var imageURL = img.images['standard_resolution'].url;
var photo = '<img src="'+ imageURL +'" />';
images.push(photo);
});
$('#instagram').html(images.join(' '));
}
});
@buccolo
Copy link

buccolo commented Jan 10, 2012

Mentos, se você tá usando o jsonp, não tinha que especificar uma callback?

@gsampaio
Copy link
Author

Success não é o callback?

@buccolo
Copy link

buccolo commented Jan 10, 2012 via email

@gsampaio
Copy link
Author

Antes eu utilizava o $.getJson(), mas neste caso ele dava pau e não soube o porque. Dai eu mudei para ajax passando jsonp e ele funcionou perfeitamente.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment