Created
January 8, 2012 15:59
-
-
Save gsampaio/1578805 to your computer and use it in GitHub Desktop.
Instagram Recent Feed Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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
commented
Jan 10, 2012
via email
Ento, teoricamente sim. Mas j tive problema com isso. O lance do jsonp
que voc especifica a callback na URL e a funo magicamente chamada.
Isso foi com a API do Tumblr, mas sei l pode ter sido alguma bizarrice.
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