/**
  * Constructor.
  *
  * @param AuthService $auth
  * @param string $api_url
  * @param string $key
  */
 public function __construct(\ModelFramework\AuthService\AuthService $auth, $api_url, $key)
 {
     $this->client = new Client();
     $this->api_url = $api_url;
     $timestamp = time();
     $company_id = (string) $auth->getMainUser()->company_id;
     $user_id = $auth->getUser()->_id;
     $login = $auth->getUser()->login;
     $key = $key;
     $hash = md5($login . $company_id . $timestamp . $key);
     $this->auth_param = ['timestamp' => $timestamp, 'login' => $login, 'owner' => $user_id, 'bucket' => $company_id, 'hash' => $hash];
     $adapter = new Curl();
     $this->client->setAdapter($adapter);
 }
Example #2
0
 /**
  * Constructor.
  *
  * @param AuthService $auth
  * @param string $api_url
  * @param string $key
  */
 public function __construct(\ModelFramework\AuthService\AuthService $auth, $key, $api_url)
 {
     $this->client = new Client();
     $this->api_url = $api_url;
     $timestamp = time();
     $company_id = (string) $auth->getMainUser()->company_id;
     $user_id = $auth->getUser()->_id;
     $login = $auth->getUser()->login;
     $key = $key;
     $hash = md5($login . $company_id . $timestamp . $key);
     $this->auth_param = ['timestamp' => $timestamp, 'login' => $login, 'owner' => $user_id, 'bucket' => $company_id, 'hash' => $hash];
     $adapter = new Curl();
     $adapter->setOptions(['curloptions' => [CURLOPT_POST => 1, CURLOPT_HTTPAUTH => CURLAUTH_BASIC, CURLOPT_USERPWD => "username:password", CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => FALSE, CURLOPT_SSL_VERIFYHOST => FALSE]]);
     $this->client->setAdapter($adapter);
 }