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']);
}