Error 403 on request via $.ajax to instagram

Asked

Viewed 196 times

0

Does anyone know why this request via error 403 ajax and URL works normally?

instagram changed their api and I found this code that serves as a media pagination, when I request via ajax it from the error (403 - prohibited) and when I request via browser url works normally.

Can someone help me?

$.ajax({
    url: 'https://www.instagram.com/graphql/query/?query_hash=472f257a40c653c64c666ce877d59d2b&variables={"id":"3937127813","first":12,"after":"AQDiT0FqVoPQ_0vSPXYUwAIBPCvt8Iw3KpsqYvixKzVDAstuZkHRyAMHo3NgnI2q1ygiLq-5PJ0TCe8daBbEy1RgkIVhY4aECXdwSZnwyWtpbQ"}',
    method: "GET",
    dataType: 'json',

    success: function (retorno) {
        console.log(retorno);
    }
  });
  • You need to be logged in or need to send cookies on request

  • Do you have an example for me? @Valdeirpsr

1 answer

0


Start Chrome like this:

chrome.exe --user-data-dir="C:/Chrome dev session" --disable-web-security

It will not solve the problem of users who access your site, it only solves the problem of your own browser, yet the script will not work for other people due to CORS, or by security you will not be able to access directly.

Instagram API this obsolete and will be discontinued

First of all according to the page https://www.instagram.com/developer/ the API you are using is obsolete and will probably soon be no longer functional, probably on 11 December 2018.

The API you should use now is the https://developers.facebook.com/products/instagram/

Using the new Instagram API

"Unfortunately" it is not only pick up and leave using have to first follow the steps described in:

And your app will probably have to go through a review before it becomes functional, by the Facebook team itself.

I think what you’re gonna need is this: https://developers.facebook.com/docs/instagram-api/insights to bring the contents, however I warn you, via Ajax will not be possible to use, you will have to use with some server-side language that makes the HTTP request directly in the facebook API, for example PHP, Asp.net, Django (python), etc.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.