Skip to content

Instantly share code, notes, and snippets.

@devudit
Created July 7, 2016 09:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devudit/3ec813a4a0a572c9fa628e89e7bb801b to your computer and use it in GitHub Desktop.
Save devudit/3ec813a4a0a572c9fa628e89e7bb801b to your computer and use it in GitHub Desktop.
Get Instagram image data using javascript/jquery
var token = '<access_token>',
hashtag='<tag>', // hashtag without # symbol
num_photos = 4;
$.ajax({
url: 'https://api.instagram.com/v1/tags/' + hashtag + '/media/recent',
dataType: 'jsonp',
type: 'GET',
data: {access_token: token, count: num_photos},
success: function(data){
console.log(data);
},
error: function(data){
console.log(data);
}
});
var token = '<access_token>',
userid = '<user_id>', // User ID - get it in source HTML of your Instagram profile :)
num_photos = 4; // how much photos do you want to get
$.ajax({
url: 'https://api.instagram.com/v1/users/' + userid + '/media/recent', // or /users/self/media/recent for Sandbox
dataType: 'jsonp',
type: 'GET',
data: {access_token: token, count: num_photos},
success: function(data){
console.log(data);
},
error: function(data){
console.log(data); // send the error notifications to console
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment