Example #1
0
 /**
  * Login as pinner
  *
  * @param string $username
  * @param string $password
  * @return bool
  * @throws AuthException
  */
 public function login($username, $password)
 {
     if ($this->request->isLoggedIn()) {
         return true;
     }
     $this->checkCredentials($username, $password);
     $post = PinnerHelper::createLoginRequest($username, $password);
     $postString = UrlHelper::buildRequestString($post);
     $this->request->clearToken();
     $response = $this->request->exec(UrlHelper::RESOURCE_LOGIN, $postString);
     $result = $this->response->checkErrorInResponse($response);
     if (!$result) {
         throw new AuthException($this->response->getLastError()['message']);
     }
     $this->request->setLoggedIn();
     return $result;
 }
Example #2
0
 /**
  * Login as pinner
  *
  * @param $username
  * @param $password
  * @return bool
  */
 public function login($username, $password)
 {
     if ($this->request->isLoggedIn()) {
         return true;
     }
     $post = PinnerHelper::createLoginRequest($username, $password);
     $postString = UrlHelper::buildRequestString($post);
     $this->request->clearToken();
     $result = $this->response->checkErrorInResponse($this->request->exec(UrlHelper::RESOURCE_LOGIN, $postString));
     if ($result) {
         $this->request->setLoggedIn();
     }
     return $result;
 }