instagram-php-scraper icon indicating copy to clipboard operation
instagram-php-scraper copied to clipboard

Getting error ( Response code is 200: OK.Something went wrong. ) while login by loginWithSessionId.

Open MohsinEusopht opened this issue 2 years ago • 6 comments

I am getting the error ( Response code is 200: OK.Something went wrong. ) while login by loginWithSessionId.

MY CODE

public function loginWithSessionId($sessionId)
    {
        // $session = ['sessionid' => $sessionId, 'csrftoken' => md5( rand( 1, 5000 ) )];
        $split = preg_split('/%/', $sessionId, -1, PREG_SPLIT_OFFSET_CAPTURE);
        $our_id= $split[0][0];
        $session = ['sessionid' => $sessionId, 'csrftoken' => md5(rand(1, 5000)), 'ds_user_id' => $our_id];

        if (!$this->isLoggedIn($session)) {
            throw new InstagramAuthException('Login with session went wrong. Please report issue.');
        } else {
            $this->userSession = $session;
        }

        return $this->generateHeaders($this->userSession);
    }


public function isLoggedIn($session = null)
    {
        if ($session === null) {
            $session = static::$instanceCache->get($this->getCacheKey());
        }
        if (!isset($session['sessionid'])) {
            return false;
        }

        $sessionId = $session['sessionid'];
        $csrfToken = $session['csrftoken'];
        $ds_user_id = $session['ds_user_id'];
        $headers = [
            'cookie' => "ig_cb=1; csrftoken=$csrfToken; sessionid=$sessionId; ds_user_id=$ds_user_id;",
            'referer' => Endpoints::BASE_URL . '/',
            'x-csrftoken' => $csrfToken,
            'X-CSRFToken' => $csrfToken,
            'user-agent' => $this->getUserAgent(),
        ];
        $response = Request::get(Endpoints::BASE_URL, $headers);
        echo "<pre>";
        var_dump($response);
        if ($response->code !== static::HTTP_OK) {
            return false;
        }
        $cookies = $this->parseCookies($response->headers);
        // if (!isset($cookies['ds_user_id'])) {
        //     return false;
        // }
        return true;
    }

Error Ref

MohsinEusopht avatar Jul 04 '22 10:07 MohsinEusopht

same problem :(

M4S3S7 avatar Jul 05 '22 16:07 M4S3S7

Same :(

arfiantorodev avatar Jul 06 '22 07:07 arfiantorodev

I am getting this error from this piece of code

require_once "../vendor/autoload.php";

use Phpfastcache\Helper\Psr16Adapter;

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

try{
    $nonPrivateAccountMedias = $instagram->getMedias($page);
    echo $nonPrivateAccountMedias[0]->getLink();

}catch(\Exception $e){
    echo json_encode([
        'success' => false,
        'code' => $e->getCode(),
        'message' => $e->getMessage()
    ]);
    die;
}

alisamie97 avatar Jul 19 '22 11:07 alisamie97

Any updates on this issue?? Still getting it.

stjnvc avatar Aug 11 '22 15:08 stjnvc

I got same with the basic account request.

trialforce avatar Oct 22 '22 18:10 trialforce

same here!!

thanhtoan1196 avatar Dec 06 '22 14:12 thanhtoan1196