Answer the question
In order to leave comments, you need to log in
How to implement work with Instagram API?
There was a task to display several fresh photos from Instagram on the site. Registered at https://www.instagram.com/developer/register/ and got an id
But when trying the code...
$.ajax({
url: 'https://api.instagram.com/oauth/authorize/',
dataType: 'json',
type: 'GET',
data: { client_id: '[_my_client_id_]' },
success: function( response ) {
console.log( response );
},
error: function( jqXHR, textStatus, errorThrown ) {
console.log( jqXHR, textStatus, errorThrown );
}
});
</script>
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' http://[_domain_].ru ' is therefore not allowed access.
Answer the question
In order to leave comments, you need to log in
Fuck the official API. If it's just to the site, it's easier to get fresh photos in JSON by emitting an AJAX request to https://www.instagram.com/[username]/?__a=1
(and don't forget the header x-requested-with: XMLHttpRequest
)
The response will include the last 12 photos.
If you need more, look for the Private API for the language you use.
I don't know if it will help you, but I heard something about JSONP.
https://learn.javascript.ru/ajax-jsonp
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question