I'm having trouble with something that seems (and theoretically should be) simple: getting the last 20 posts an instagram user made.
Ideally, this could be achieved without even having to create a client. If that's not possible, it should be achieved without requiring the end-user to log into instagram, as I only want to display posts from a particular user regardless of who enters the site and whether or not they're logged in to instagram.
I found a pretty straightforward end-point which provides JSON with the exact data I need (https://www.instagram.com/{username}/media/
), but I can't find any reference to it on the docs. Regardless, I tried accessing it through a simple AJAX GET, and received two different errors:
No 'Access-Control-Allow-Origin' header is present on the requested resource.
when trying the call expecting a JSON response.Unexpected token :
when trying the call expecting a JSONP response.
The code is the same in both cases save for the dataType
line, and goes as follows:
$.ajax({
type: 'GET',
dataType: 'jsonp',
crossDomain: true,
url: 'https://www.instagram.com/{username}/media/',
success: function(data) {
console.log(data);
}
});
I searched all over for some kind of answer, but couldn't really find one. I'd like to know at least if the overall method is correct, or if nowadays the /{username}/media
node doesn't work for retrieving data and it's just something they just didn't get around to take down / left for informational purpose.
Any help will be greatly appreciated, thanks!