InstagramScraper\Endpoints::getAccountJsonLink PHP Method

    public static function getAccountJsonLink($username)
    {
        return str_replace('{username}', urlencode($username), Endpoints::ACCOUNT_JSON_INFO);
    }

Usage Example

Ejemplo n.º 1
0
 public static function getAccount($username)
 {
     $response = Request::get(Endpoints::getAccountJsonLink($username));
     if ($response->code === 404) {
         throw new InstagramNotFoundException('Account with given username does not exist.');
     }
     if ($response->code !== 200) {
         throw new InstagramException('Response code is ' . $response->code . '. Body: ' . $response->body . ' Something went wrong. Please report issue.');
     }
     $userArray = json_decode($response->raw_body, true);
     if (!isset($userArray['user'])) {
         throw new InstagramException('Account with this username does not exist');
     }
     return Account::fromAccountPage($userArray['user']);
 }