postaddictme / instagram-php-scraper

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

Fatal error: Uncaught InstagramScraper\Exception\InstagramException: Response code is 302. #823

Closed kagandev closed 3 years ago

kagandev commented 3 years ago

My code is:

`require __DIR__ . '/vendor/autoload.php';
ini_set('display_errors', 1);
error_reporting(E_ALL);

$instagram = new \InstagramScraper\Instagram(new \GuzzleHttp\Client());

// For getting information about account you don't need to auth:

$account = $instagram->getAccount('kevin');

// Available fields
echo "Account info:\n";
echo "Id: {$account->getId()}\n";
echo "Username: {$account->getUsername()}\n";
echo "Full name: {$account->getFullName()}\n";
echo "Biography: {$account->getBiography()}\n";
echo "Profile picture url: {$account->getProfilePicUrl()}\n";
echo "External link: {$account->getExternalUrl()}\n";
echo "Number of published posts: {$account->getMediaCount()}\n";
echo "Number of followers: {$account->getFollowsCount()}\n";
echo "Number of follows: {$account->getFollowedByCount()}\n";
echo "Is private: {$account->isPrivate()}\n";
echo "Is verified: {$account->isVerified()}\n";`

It was working until 30 minutes ago. I can't understand why.

goldfischart commented 3 years ago

We have the same issue. Nearly ever request end in a 302 Error

restyler commented 3 years ago

If you are trying to access public account, chances are your ip just got banned by Instagram, so it redirects you to /login page when you try to access profile page. Take a look at proxified version of this scaper to mitigate the issue. https://github.com/restyler/instagram-php-scraper

nalin88 commented 3 years ago

then how do we login on Instagram with server IP?? I tried to log in with this code

$instagram = \InstagramScraper\Instagram::withCredentials(new \GuzzleHttp\Client(), 'xxx', 'xxx', new Psr16Adapter('Files'));
$instagram->login();

but it gives an error because I need to verify it with server IP using opt or what so ever method... please guide us ... a lot of us are facing the same issue

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

rangelrmorais commented 2 years ago

Same here ` Warning: Undefined property: stdClass::$authenticated in /home/xxx/public_html/wp-content/themes/Newspaper-child/includes/vendor/raiym/instagram-php-scraper/src/InstagramScraper/Instagram.php on line 2206

Fatal error: Uncaught InstagramScraper\Exception\InstagramAuthException: User credentials are wrong. in /home/xxx/public_html/wp-content/themes/Newspaper-child/includes/vendor/raiym/instagram-php-scraper/src/InstagramScraper/Instagram.php:2207 Stack trace: #0 /home/xxx/public_html/wp-content/themes/Newspaper-child/includes/get.php(13): InstagramScraper\Instagram->login() #1 {main} thrown in /home/xxx/public_html/wp-content/themes/Newspaper-child/includes/vendor/raiym/instagram-php-scraper/src/InstagramScraper/Instagram.php on line 2207`