postaddictme / instagram-php-scraper

Get account information, photos, videos, stories and comments.
https://packagist.org/packages/raiym/instagram-php-scraper
MIT License
3.07k stars 800 forks source link

Response code is 401: Unauthorized.Something went wrong. Please report issue. #1104

Open Arish68 opened 1 year ago

Arish68 commented 1 year ago

Working fine on localhost but on Production level it return an error Response code is 401: Unauthorized.Something went wrong. Please report issue.

Code Snippet: $instagram->getAccountInfo('username');

IrfanPatelDev commented 1 year ago

The same issue please someone help with this issue. Or please share more info about using a proxy server. my proxy server is also throwing the same error.

Arish68 commented 1 year ago

@IrfanPatelDev use this code to fetch public userdata by username

$instagram = new \InstagramScraper\Instagram(new \GuzzleHttp\Client()); $nonPrivateAccountMedias = $instagram->getMedias('kevin'); echo $nonPrivateAccountMedias[0]->getLink();

kindly check example folder and i hope you will never use proxy server https://github.com/postaddictme/instagram-php-scraper/tree/master/examples

IrfanPatelDev commented 1 year ago

@IrfanPatelDev use this code to fetch public userdata by username

$instagram = new \InstagramScraper\Instagram(new \GuzzleHttp\Client()); $nonPrivateAccountMedias = $instagram->getMedias('kevin'); echo $nonPrivateAccountMedias[0]->getLink();

kindly check example folder and i hope you will never use proxy server https://github.com/postaddictme/instagram-php-scraper/tree/master/examples Thanks @Arish68 for your reply, I tried this but still no luck :(

fverdicchio commented 1 year ago

I have same problem. On localhost works but on production server i haven't authorization. I'm using proxy.

beshoo commented 1 year ago

All these problems are related to the proxy, that is why it works on your local connection because you are using your telecom connection which is a residential connection.

You may buy a proxy but it is very expansive, each 1 GB of traffic = 25 UDS. if any one is interested in this type of proxy you can contact me.

Regards

brucekasinsky commented 1 year ago

im using proxy, using this library one year, in last 10 days, only getmedias showing error 401. I change the proxy to rotating, not sticky and all is ok now

Arish68 commented 1 year ago

@brucekasinsky please explain your solution (proxy to rotating)

brucekasinsky commented 1 year ago

@Arish68

First you have to get a good proxy, for me the only one i get working with facebook is smartproxy, residencial plan. I test like five and have the problem with 401 error. There are option to use sticky and rotating.

The main difference between sticky and rotating proxies is that a sticky proxy associates a single IP address per user request while a rotating proxy assigns various IP addresses for each new request.

fabioselau077 commented 1 year ago

Same here... same using this rotating proxy

MJRamon commented 1 year ago

Everything was working, and then I keep getting 401 Unauthorized. Is it some kind of ban by Instagram? How this can be fixed?

jhob101 commented 1 year ago

Use a proxy service. Instagram bans IPS if it defects unusual activity from them.

On Sun, 19 Feb 2023, 18:28 MJRamon, @.***> wrote:

Everything was working, and then I keep getting 401 Unauthorized. Is it some kind of ban by Instagram? How this can be fixed?

— Reply to this email directly, view it on GitHub https://github.com/postaddictme/instagram-php-scraper/issues/1104#issuecomment-1436059575, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAXC3UDK2BKU643IWPAN7VDWYJQ3JANCNFSM6AAAAAAR4QWNJ4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

skmachine commented 1 year ago

I am now using https://rapidapi.com/neotank/api/instagram130/ and they somehow manage to download account json info (I am using /account-info endpoint of this api and it returns basic account info and 12 latest posts in JSON) - and they do not require to supply any cookies or login info - but this is a paid API.. it's still cheaper than purchase very expensive proxies per GB tho