whizzzkid / instagram-proxy-api

CORS compliant API to access Instagram's public data
https://nishantarora.in/building-your-image-gallery-using-public-instagram-API.naml
261 stars 48 forks source link

No longer works #15

Closed egfx closed 6 years ago

egfx commented 6 years ago

https://igpi.ga/whizzzkid/media/?__a=1

{"error":"Denying request from referer: undefined"}

yashkovskiy commented 6 years ago

same for me, any advice?

mhgbrown commented 6 years ago

Probably because this has also stopped working 😭 https://www.instagram.com/whizzzkid/media/

yashkovskiy commented 6 years ago

got it, do you know of any alternative?

egfx commented 6 years ago

nope! There goes my app ;\

whizzzkid commented 6 years ago

There goes everything we've worked for. I already updated the readme yesterday, IG disabled media queries. However the advanced params still work, but pagination is difficult. I have a solution in mind but I will be working on it over the weekend.

yashkovskiy commented 6 years ago

https://igpi.ga/username/media/?__a=1 gives the same mistake referrer undefined. Hope you`ll come up with some solution.

whizzzkid commented 6 years ago

@yashkovskiy you're confusing between two problems.

Problem 1: Instagram disabled all media queries, i.e. any request with /media in them resolves to 404. For which you can use the advanced params.

Problem 2: As mentioned in issue #14 denying requests with undefined referrers is a feature I introduced to prevent abuse. Which means it will work fine with links from a web page or in your app. Try clicking this: https://igpi.ga/whizzzkid/?__a=1

does this makes it clear?

yashkovskiy commented 6 years ago

@whizzzkid 2017-11-08_15-10-34 your link gives me the same result in google chrome browser (see screenshot), as well as all other requests from my app. I`m using PHP and curl to make a request.

whizzzkid commented 6 years ago

You need to understand how referrers work. https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referer

A quick primer, whenever you click a link or a script calls a url from a page, browser automatically appends the referrer parameter to the request, which implies if you're typing a link in your url then the browser has no referrer to send and it will hence be undefined.

e.g. clicking all the links below will work, copy pasting them into address bar won't.

Does that make sense?

mhgbrown commented 6 years ago

Oh wait, my mistake sorry! Just needed to change the URL.

mhgbrown commented 6 years ago

I guess another disadvantage of this alternative is that if the media is a video, it does not include a the URL of the video file.

yashkovskiy commented 6 years ago

@whizzzkid it does make sense, but for some reason when making a request from my server`s script I still get undefined :( it just a cron script on my web hosting, how to fix it, do you know?

Nuneshere commented 6 years ago

Hey whizz,

As I mentioned days ago, your work is fucking amazing. I know that the ig messed it up, but please keep up with this project, it's the only one with that focus, it's amazing man...

whizzzkid commented 6 years ago

@whizzzkid it does make sense, but for some reason when making a request from my server`s script I still get undefined :( it just a cron script on my web hosting, how to fix it, do you know?

@yashkovskiy this is the exact abuse I wanted to stop. The purpose of this proxy was to provide instagram's public data in a cors compliant method so that personal blogs/websites could use this to show their instagram posts. If you just wanted to your server to scrape instagram then you can hit the instagram api directly and it should be fine, you don't need a proxy. Not only will it be faster, but also help reduce loads on my server.

Does that make sense?

axpence commented 6 years ago

@whizzzkid thanks for your work here!

What is the call to the Instagram API you'd recommend servers make now that /media isn't working? I tried the url below, doesn't work:

https://www.instagram.com/kimkardashian/media/?__a=1

shefaligupta commented 6 years ago

@axpence try using https://www.instagram.com/kimkardashian/?__a=1 or https://igapi.ga/kimkardashian/?__a=1&callback=foo for cors compliance

axpence commented 6 years ago

@shefaligupta thanks for the suggestion, I did try the above, however, /media had pagination functionality and the above only permits a single page (to my knowledge). What parameters (if any) can be used to add pagination?

Also - does anybody know where these API's are documented, if at all?

whizzzkid commented 6 years ago

@axpence @shefaligupta @yashkovskiy @Nuneshere @mhgbrown @egfx

I implemented a workaround. https://igpi.ga/graphql/query/?user_id=1606740656&count=3 does this work for you guys?

axpence commented 6 years ago

No, I get the following error:

{"error":"Denying request from referer: undefined"}

On Fri, Nov 10, 2017 at 15:43 Nishant Arora notifications@github.com wrote:

@axpence https://github.com/axpence @shefaligupta https://github.com/shefaligupta @yashkovskiy https://github.com/yashkovskiy @Nuneshere https://github.com/nuneshere @mhgbrown https://github.com/mhgbrown @egfx https://github.com/egfx

I implemented a workaround. https://igpi.ga/graphql/query/?user_id=1606740656&count=3 does this work for you guys?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/whizzzkid/instagram-reverse-proxy/issues/15#issuecomment-343616021, or mute the thread https://github.com/notifications/unsubscribe-auth/ABscnJiMWQrk-RMC-iEqF1q-WQ0sEBE2ks5s1N-1gaJpZM4QVmv0 .

whizzzkid commented 6 years ago

@axpence you tried opening it from your email. It will give you this error. the workaround is live on my website https://nishantarora.in/ check it out there.

egfx commented 6 years ago

Here is my experience:

Clicked link from github notification email: error Direct copy and paste: error Clicked link from this thread: works

This is great. Thanks for your hard work on this!

axpence commented 6 years ago

It works! What is the underlying instagram query (without the reverse proxy) ?

whizzzkid commented 6 years ago

@axpence . https://igpi.ga/graphql/query/?user_id=1606740656&count=3 fetches data from https://www.instagram.com/graphql/query/?query_id=17888483320059182&variables=%7B%22id%22%3A%221606740656%22%2C%22first%22%3A3%2C%22after%22%3A%22%22%7D

axpence commented 6 years ago

@whizzzkid where did you find the documentation for the /graphql/query/ API?

I see that variables=%7B%22id%22%3A%221606740656%22%2C%22first%22%3A3%2C%22after%22%3A%22%22%7D when url_decoded becomes: variables={"id":"1606740656","first":3,"after":""}. I'd love to understand how to hit this API directly and what the paramaters mean. Thanks!

whizzzkid commented 6 years ago

@axpence please open a different issue as question for this one.

whizzzkid commented 6 years ago

Turns out this implementation takes just half the time as before, on my own website, the average loading time for the response is 149ms vs 290ms before. The most probable reason is, earlier loading a response with 20 results and then stripping them down to the count was an overhead which we do not need to deal with anymore.

PudgeTheFish commented 6 years ago

Hey, I think the proxy isn't working anymore. I'm getting the following error when I follow this link in your readme "https://igpi.ga/whizzzkid/media?count=3"

The error: {"code":2,"desc":"Failed to fetch from Instagram.","info":"encountered: TypeError: Cannot read property 'user' of undefinedfetched:{\"message\": \"forbidden\", \"status\": \"fail\"}"}