public function login($username, $password)
{
$this->setupAsNewDevice();
$this->setDeviceId($this->generateDeviceId(md5($username . $password)));
$request = new LoginRequest($this, $username, $password);
$response = $request->execute();
if (!$response->isOk()) {
if ($response->isCheckpointRequired()) {
throw new InstagramException(sprintf("Login Failed: [%s] %s\nGo to this URL in your web browser to continue:\n%s", $response->getStatus(), $response->getMessage(), $response->getCheckpointUrl()));
}
throw new InstagramException(sprintf("Login Failed: [%s] %s", $response->getStatus(), $response->getMessage()));
}
$this->setLoggedInUser($response->getLoggedInUser());
return $response;
}