public static function get_instance()
 {
     if (!isset(self::$instance)) {
         $c = __CLASS__;
         self::$instance = new $c();
     }
     return self::$instance;
 }
Exemplo n.º 2
0
 /**
  * @param string $username The KeyLemon API username
  * @param string $client_key The KeyLemon API key
  * @param String $entryPointURL The URL of the server that host the API
  * @throws \KL_Exception If the user isn't allowed to access to the API
  */
 public function __construct($username, $client_key, $server, $user_agent = "PHP Wrapper")
 {
     if (is_null($username) || is_null($client_key)) {
         throw new KL_Exception(KL_Errors::Wrong_Parameters);
     }
     $this->base64_auth = base64_encode($username . ':' . $client_key);
     //instantiate links
     $this->get_face_link = new Relation_Link($this->base64_auth, $server . '/api/', 'face/', 'GET');
     $this->post_face_link = new Relation_Link($this->base64_auth, $server . '/api/', 'face/', 'POST');
     $this->post_multiview_link = new Relation_Link($this->base64_auth, $server . '/api/', 'face_detail/', 'POST');
     $this->get_model_link = new Relation_Link($this->base64_auth, $server . '/api/', 'model/', 'GET');
     $this->post_model_link = new Relation_Link($this->base64_auth, $server . '/api/', 'model/', 'POST');
     $this->post_speaker_model_link = new Relation_Link($this->base64_auth, $server . '/api/', 'speaker/model/', 'POST');
     $this->put_model_link = new Relation_Link($this->base64_auth, $server . '/api/', 'model/', 'PUT');
     $this->delet_modelLink = new Relation_Link($this->base64_auth, $server . '/api/', 'model/', 'DELETE');
     $this->get_group_link = new Relation_Link($this->base64_auth, $server . '/api/', 'group/', 'GET');
     $this->post_group_link = new Relation_Link($this->base64_auth, $server . '/api/', 'group/', 'POST');
     $this->put_group_link = new Relation_Link($this->base64_auth, $server . '/api/', 'group/', 'PUT');
     $this->delete_group_link = new Relation_Link($this->base64_auth, $server . '/api/', 'group/', 'DELETE');
     $this->get_identity_link = new Relation_Link($this->base64_auth, $server . '/api/', 'identity/', 'GET');
     $this->post_identity_link = new Relation_Link($this->base64_auth, $server . '/api/', 'identity/', 'POST');
     $this->post_identity_face_link = new Relation_Link($this->base64_auth, $server . '/api/', 'identity/face/', 'POST');
     $this->post_identity_speaker_link = new Relation_Link($this->base64_auth, $server . '/api/', 'identity/speaker/', 'POST');
     $this->put_identity_link = new Relation_Link($this->base64_auth, $server . '/api/', 'identity/', 'PUT');
     $this->delete_identity_link = new Relation_Link($this->base64_auth, $server . '/api/', 'identity/', 'DELETE');
     $this->recognize_face_link = new Relation_Link($this->base64_auth, $server . '/api/', 'recognize/', 'POST');
     $this->recognize_speaker_link = new Relation_Link($this->base64_auth, $server . '/api/', 'speaker/recognize/', 'POST');
     $this->recognition_status = new Relation_Link($this->base64_auth, $server . '/api/', 'status/', 'GET');
     $this->get_usage_link = new Relation_Link($this->base64_auth, $server . '/api/', 'infos/', 'GET');
     $this->get_stream_link = new Relation_Link($this->base64_auth, $server . '/api/', 'stream/', 'GET');
     $this->post_stream_link = new Relation_Link($this->base64_auth, $server . '/api/', 'stream/', 'POST');
     $this->get_image_link = new Relation_Link($this->base64_auth, $server . '/api/', 'image/', 'GET');
     Server_Connection::get_instance()->user_agent = $user_agent;
 }
Exemplo n.º 3
0
 public function download($resource = null)
 {
     return Server_Connection::get_instance()->download($this->auth, $this->base_url, $this->path . (is_null($resource) ? '' : $resource));
 }