email = $email; $this->apikey = $apikey; $this->url = 'https://www.boxis.net/xmlapi.php'; } public function call($apitype, $command, $params, $timestamp){ $this->params = $params; $this->params['version'] = self::VERSION; $this->params['username'] = $this->email; $this->params['timestamp'] = $timestamp; $this->params['authcode'] = md5($timestamp. $this->apikey); $this->params['section'] = $apitype; $this->params['action'] = $command; $ch = curl_init(); $post = ''; foreach($this->params as $k => $v) { $post .= $k.'='.urlencode($v).'&'; } $chOptions = array ( CURLOPT_URL => trim ($this->url), CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => false, CURLOPT_SSL_VERIFYHOST => false, CURLOPT_TIMEOUT => 90, CURLOPT_POST => true, CURLOPT_POSTFIELDS => trim($post, '&') ); // $chOptions['CURLOPT_USERPWD'] = 'user:password'; // htaccess username and password (set if used) curl_setopt_array($ch, $chOptions); $out = curl_exec($ch); curl_close($ch); return $params['returntype'] == 'json' ? json_decode($out,true) : $out; // } } /* API LOGIN DETAILS */ $email = 'your@email.com'; // your username $apikey = '1234567890'; // your apikey $timestamp = time(); /* API COMMAND DETAILS */ $apitype = 'domains'; $command = ''; $params = array( 'returntype' => 'json' ); /* PROCESS THE ACTION */ $boxisAPI = new BoxisAPIConnection($email, $apikey); $return = $boxisAPI->call($apitype, $command, $params, $timestamp); /* TIMESTAMP SYNCHRONIZATION (JSON EXAMPLE) if($return['timestamperror']) { $timestamp = $return['timestamp']; $return = $boxisAPI->call($apitype, $command, $params, 'json', $timestamp); } */ /* TIMESTAMP SYNCHRONIZATION (XML EXAMPLE)*/ /* if($return->timestamperror) { $timestamp = $return->timestamp; $return = $boxisAPI->call($apitype, $command, $params, 'xml', $timestamp); } /* /* RETURNED VALUE */ print_r($return); ?>