nuwaninfo Posted March 3, 2009 Share Posted March 3, 2009 addclient does not work. It says Bad request. i modified necessary details like $url, $username, $password according to my site $url = "http://www.yourdomain.com/whmcs/includes/api.php"; # URL to WHMCS API file $username = "Admin"; # Admin username goes here $password = "demo"; # Admin password goes here $postfields["action"] = "addclient"; $postfields["firstname"] = "Test"; $postfields["lastname"] = "User"; $postfields["companyname"] = "WHMCS"; $postfields["email"] = "demo@whmcs.com"; $postfields["address1"] = "123 Demo Street"; $postfields["city"] = "Demo"; $postfields["state"] = "Florida"; $postfields["postcode"] = "AB123"; $postfields["country"] = "US"; $postfields["phonenumber"] = "123456789"; $postfields["password2"] = "demo"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $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]; } $data = explode(";",$data); foreach ($data AS $temp) { $temp = explode("=",$temp); $results[$temp[0]] = $temp[1]; } print_r($data);die(); The link to my site is: http://www.superquicksite.com/test_api.php your help is much appriciated. Thank you. 0 Quote Link to comment Share on other sites More sharing options...
kurbot Posted March 4, 2009 Share Posted March 4, 2009 I had the same problem, and if remember correctly all you need o do is pass along the username and password in the postfields.. for example $whmcsurl= "http://www.yourdomain.com/whmcs/includes/api.php"; # URL to WHMCS API file $whmcsadminusername= "Admin"; # Admin username goes here $whmcsadminpassword= "demo"; # Admin password goes here $postfields["username"] = $whmcsadminusername; $postfields["password"] = md5($whmcsadminpassword); $postfields["action"] = "addclient"; $postfields["firstname"] = "Test"; $postfields["lastname"] = "User"; $postfields["companyname"] = "WHMCS"; $postfields["email"] = "demo@whmcs.com"; $postfields["address1"] = "123 Demo Street"; $postfields["city"] = "Demo"; $postfields["state"] = "Florida"; $postfields["postcode"] = "AB123"; $postfields["country"] = "US"; $postfields["phonenumber"] = "123456789"; $postfields["password2"] = "demo"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $whmcsurl); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $data = curl_exec($ch); curl_close($ch); $data = explode(";",$data); foreach ($data AS $temp) { $temp = explode("=",$temp); $results[$temp[0]] = $temp[1]; } if ($results["result"]=="success") { echo "User Generated Successfully<br /> <br /> "; } else { # An error occured echo "The following error occured: ".$results["message"]; } 0 Quote Link to comment Share on other sites More sharing options...
nuwaninfo Posted March 5, 2009 Author Share Posted March 5, 2009 Hi kurbot, Thank you for your reply. But it did not work. Regards, Nuwan 0 Quote Link to comment Share on other sites More sharing options...
nuwaninfo Posted March 5, 2009 Author Share Posted March 5, 2009 Hi, It is working now from your help. Thank you very much. Regards, Nuwan 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.