Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class api_whmcs {
- var $url;
- var $username;
- var $password;
- var $result;
- public function __construct($url,$username,$password){
- if(substr($url,0,7) != "http://") $this->url = "http://".$url."/includes/api.php"; else $this->url = $url."/includes/api.php";
- $this->username = $username;
- $this->password = md5($password);
- }
- public function post($postfields){
- $postfields["username"] = $this->username;
- $postfields["password"] = $this->password;
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $this->url);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_TIMEOUT, 100);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
- $data = curl_exec($ch);
- curl_close($ch);
- $data = explode(";",$data);
- foreach ($data AS $temp) {
- $temp = explode("=",$temp);
- $results[$temp[0]] = $temp[1];
- }
- $this->result['result'] = $results["result"];
- $this->result['message'] = $results["message"]
- }
- public function query($command){
- if(is_array($command)){
- foreach($command as $query){
- $this->post($query);
- }
- } else {
- $this->post($query);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement