FAQ - Cloud Desk 3 - Client API V2

Cloud Desk 3 - Client API V2

25.10.2019 2608


From CloudDesk 3 Version 1.0.5 we have updated the client api to be compatible with PHP 7.2 and higher. You can integrate this into your own website where your client create a user or change their data or delete their user profile. You need curl installed on your server and pass the vars to your CloudDesk 3 installation, it will then create, update or delete a user from your CloudDesk 3 client database.

Should you run our CMS you can also share the hashed password so clients don't need to have two passwords.

$CD_URL = "url_where_helpdesk_has_been_installed"; // url to the helpdesk installation
$CD_API_KEY = ""; // can be found in your operator panel - settings
$CD_SID_KEY = ""; // can be found in your operator panel - settings
$CD_ACTION = "new"; // (new,update,delete)
$CD_NAME = ""; // name from client
$CD_EMAIL = ""; // valid email address from client
$CD_OLDEMAIL = ""; // valid old email address from client (same as above or old one in case of a change)
$CD_HASHEDPASS = ""; // password hash from CMS
$CD_MAINOPID = "3"; // (single id from the main operator account)
$CD_CHATDEP = "1"; // (single id or multiple id's (1,2,3))
$CD_SUPPORTDEP = "1"; // (single id or multiple id's (1,2,3))
$CD_FAQCAT = "1"; // (single id or multiple id's (1,2,3))
$CD_CREDITS = "0"; // (numeric )
$CD_VALIDTILL = ""; // (0000-00-00 / Year-Month-Day)
	
$CD_STR = "sid=".$CD_SID_KEY."&action=".$CD_ACTION."&name=".$CD_NAME."&email=".$CD_EMAIL."&oldemail=".$CD_OLDEMAIL."&pass=".$CD_HASHEDPASS."&mainopid=".$CD_MAINOPID."&chatdep=".$CD_CHATDEP."&supportdep=".$CD_SUPPORTDEP."&faqcat=".$CD_FAQCAT."&credits=".$CD_CREDITS."&valid=".$CD_VALIDTILL;
	
$ivlen = openssl_cipher_iv_length($cipher="AES-128-CBC");
$iv = openssl_random_pseudo_bytes($ivlen);
$ciphertext_raw = openssl_encrypt($CD_STR, $cipher, $CD_API_KEY, $options=OPENSSL_RAW_DATA, $iv);
$hmac = hash_hmac('sha256', $ciphertext_raw, $key, $as_binary=true);
$CD_STR = strtr(base64_encode($iv.$hmac.$ciphertext_raw), '+/=', '._-');

$CD_CURL = curl_init();
	
// set URL and other appropriate options
curl_setopt($CD_CURL, CURLOPT_URL, $CD_URL.'/index.php?p=api&sp='.$CD_STR);
curl_setopt($CD_CURL, CURLOPT_SSL_VERIFYPEER,  false);
curl_setopt($CD_CURL, CURLOPT_HEADER, 0);
	
// grab URL and pass it to the browser
curl_exec($CD_CURL);
	
// close cURL resource, and free up system resources
curl_close($CD_CURL);

In case you are using the rewrite mode, please use following URL instead:

curl_setopt($CD_CURL, CURLOPT_URL, $CD_URL.'/api/'.$CD_STR);