Reputation: 4363
I would like to have the recent posts of an specific user, like Banksy. I came up with the following, but it will give me an error of:
GET https://api.instagram.com/v1/users/banksy/media/recent/?access_token={token}&callback=jQuery11110924438442569226_1445956181244&_=1445956181245
My ajax call looks like this:
$.ajax({
type: "GET",
dataType: "jsonp",
cache: false,
url: "https://api.instagram.com/v1/users/banksy/media/recent/?access_token={token}",
success: function(response) {
console.log('jfsdahuifhasudh')
console.log(response);
// placing the images on the page
// for (var i = 0; i < 6; i++) {
var html = '<a href="' + response.data[i].link + '" >'+
'<img src="' + response.data[i].images.low_resolution.url + '" alt="thumbnail" /></a>';
$(".instafeed").html(html);
// }
},
error: function(data) {
console.log('We have a problem!');
}
});
Upvotes: 3
Views: 17386
Reputation: 11297
You're using the username in your query; banksy
in your case. Resolve the username
into ID then use the id
in your query. For example;
https://api.instagram.com/v1/users/45951573/media/recent/?access_token={token}
*The API will return posts only if the account is public.
To get posts tagged with a specific hashtag use:
https://api.instagram.com/v1/tags/{tag-name}/media/recent?access_token={token}
Further reading: Instagram API; Tags
instaJS is a jQuery plugin I wrote in past. What makes this plugin unique is that it accepts username
instead of forcing users to resolve their id
. Completely Free to use :), and of course contribution is always welcomed InstaJS on Github
Upvotes: 4