Skip to content

Commit

Permalink
fix readme and login error http status 302 (#942)
Browse files Browse the repository at this point in the history
* Update README.md

fix incomplete installation guide and wrong example

* fix login issue of HTTP 302

fix login issue of HTTP 302

* Update README.md

add phpfastcache/phpfastcache
  • Loading branch information
am05mhz authored Aug 14, 2021
1 parent 627dc5f commit 051dbf5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ This library is based on the Instagram web version. We develop it because nowada

## Code Example
```php
$instagram = \InstagramScraper\Instagram::withCredentials(new \GuzzleHttp\Client(), 'username', 'password');
use Phpfastcache\Helper\Psr16Adapter;

$instagram = \InstagramScraper\Instagram::withCredentials(new \GuzzleHttp\Client(), 'username', 'password', new Psr16Adapter('Files'));
$instagram->login();
$account = $instagram->getAccountById(3);
echo $account->getUsername();
Expand Down Expand Up @@ -51,11 +53,11 @@ $account = $instagram->getAccount('kevin');
### Using composer

```sh
composer.phar require raiym/instagram-php-scraper
composer.phar require raiym/instagram-php-scraper phpfastcache/phpfastcache
```
or
```sh
composer require raiym/instagram-php-scraper
composer require raiym/instagram-php-scraper phpfastcache/phpfastcache
```

### If you don't have composer
Expand Down
4 changes: 2 additions & 2 deletions src/InstagramScraper/Instagram.php
Original file line number Diff line number Diff line change
Expand Up @@ -1819,7 +1819,7 @@ public function login($force = false, $twoStepVerificator = null)
$response = $this->verifyTwoStep($response, $cookies, $twoStepVerificator);
}

if ($response->code !== static::HTTP_OK) {
if ($response->code !== static::HTTP_OK && $response->code !== static::HTTP_FOUND) {
if ((is_string($response->code) || is_numeric($response->code)) && is_string($response->body)) {
throw new InstagramAuthException('Response code is ' . $response->code . '. Body: ' . $response->body . ' Something went wrong. Please report issue.', $response->code);
} else {
Expand Down Expand Up @@ -1973,7 +1973,7 @@ private function verifyTwoStep($response, $cookies, TwoStepVerificationInterface

$response = Request::post($url, $headers, $post_data);

if ($response->code !== static::HTTP_OK) {
if ($response->code !== static::HTTP_OK && $response->code !== static::HTTP_FOUND) {
throw new InstagramAuthException('Something went wrong when try two step verification and enter security code. Please report issue.', $response->code);
}

Expand Down

0 comments on commit 051dbf5

Please sign in to comment.