K
K
Ken Jee2016-09-24 19:41:23
JavaScript
Ken Jee, 2016-09-24 19:41:23

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
15d33f73dfc54b548eac4191746b3597.jpg
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>

An error occurs:
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin ' http://[_domain_].ru ' is therefore not allowed access.

f550f5f6056e4e288008712a33c8e599.jpg
Please tell me how to solve this problem.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
hoarywolf, 2016-09-24
@Machez

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.

S
Sergei Gribok, 2016-09-25
@FungusWarrior

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 question

Ask a Question

731 491 924 answers to any question