InstagramScraper\Model\Account::fromAccountPage PHP Method

fromAccountPage() public static method

public static fromAccountPage ( $userArray )
    public static function fromAccountPage($userArray)
    {
        $instance = new self();
        $instance->username = $userArray['username'];
        $instance->followsCount = $userArray['follows']['count'];
        $instance->followedByCount = $userArray['followed_by']['count'];
        $instance->profilePicUrl = $userArray['profile_pic_url'];
        $instance->id = $userArray['id'];
        $instance->biography = $userArray['biography'];
        $instance->fullName = $userArray['full_name'];
        $instance->mediaCount = $userArray['media']['count'];
        $instance->isPrivate = $userArray['is_private'];
        $instance->externalUrl = $userArray['external_url'];
        $instance->isVerified = $userArray['is_verified'];
        return $instance;
    }

Usage Example

 public static function getLastLikesByCode($code)
 {
     $response = Request::get(Endpoints::getLastLikesByCodeLink($code));
     if ($response->code === 404) {
         throw new InstagramNotFoundException('Media with this shortcode doesn\'t exist');
     }
     if ($response->code !== 200) {
         throw new InstagramException('Response code is ' . $response->code . '. Body: ' . $response->body . ' Something went wrong. Please report issue.');
     }
     $jsonResponse = json_decode($response->raw_body, true);
     $users = [];
     foreach ($jsonResponse['likes']['nodes'] as $userArray) {
         $users[] = Account::fromAccountPage($userArray['user']);
     }
     return $users;
 }