Search code examples
javajsonapihttprequestinstagram-api

Instagram ?__a=1 API giving HTML login page in response issue


I have been using this instagram api for a very long time in Javascript.

https://www.instagram.com/username/?__a=1

Now I moved the same code to JAVA and making get call using HTTP REQUEST which is obviously a GET call.

But now, I am getting login page of instagram in my production but JSON data on my local machine. I am little bit confused why it is happening. If anyone could help will be great for me. Thank You


Solution

  • You want to know what's different? Well, a lot.

    Calling https://www.instagram.com/username/?__a=1 in your browser has access to the LocalStorage, SessionStorage and Cookies. In basic Java, you have none of the above.

    And since you have to send a session identifier to Instagram, your Java code won't work without duplicating this logic.

    However, the URL you're using is actually not a public API. You may consider using the Basic Display API instead and start from there.