Instagram\Instagram::followUser PHP Method

followUser() public method

Follow User
public followUser ( string | User $userId ) : CreateFriendshipResponse
$userId string | Instagram\API\Response\Model\User User or User Id to Follow
return Instagram\API\Response\CreateFriendshipResponse
    public function followUser($userId)
    {
        if (!$this->isLoggedIn()) {
            throw new InstagramException("You must be logged in to call followUser().");
        }
        if ($userId instanceof User) {
            $userId = $userId->getPk();
        }
        $request = new CreateFriendshipRequest($this, $userId);
        $response = $request->execute();
        if (!$response->isOk()) {
            throw new InstagramException(sprintf("Failed to followUser: [%s] %s", $response->getStatus(), $response->getMessage()));
        }
        return $response;
    }