Example #1
0
 /**
  * Authorize to get a token
  * @param string $username
  * @param string $password
  * @return \Afosto\ActiveAnts\ApiClient
  */
 public function authorize()
 {
     if (App::getInstance()->cache->getCache('token')) {
         $this->token = App::getInstance()->cache->getCache('token');
     }
     if (is_null($this->token)) {
         $this->request('token', array('grant_type' => 'password', 'username' => $this->username, 'password' => $this->password));
         $this->token = 'Bearer ' . $this->response->getParam('access_token');
         App::getInstance()->cache->setCache('token', $this->token, $this->response->getParam('expires_in'));
     }
     return $this;
 }