tobaniyi Posted March 2, 2011 Share Posted March 2, 2011 I tried using the following to code change the password of an account but I got the error Command not found. Can someone help?? $url = "http://www.mysite.com/includes/api.php"; # URL to WHMCS API file $username = "admin"; # Admin username goes here $password = "password"; # Admin password goes here $postfields["username"] = $username; $postfields["password"] = md5($password); $postfields["action"] = "modulechangepw"; $postfields["serviceid"] = "1"; $postfields["serverpassword"] = "newpassword123"; $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]; } if ($results["result"]=="success") { echo "success"; } else { # An error occured echo "The following error occured: ".$results["message"]; } Interestingly, I tried using the Update Client Product API instead but that only changed the username and password of the account to the admin username and password. I'm really lost. The code I used for that is $url = "http://www.mysite.com/includes/api.php"; # URL to WHMCS API file $username = "admin"; # Admin username goes here $password = "password"; # Admin password goes here $postfields["username"] = $username; $postfields["password"] = $password; $postfields["action"] = "updateclientproduct"; $postfields["serviceid"] = '1'; $postfields["serviceusername"] = 'username'; $postfields["servicepassword"] = 'newpassword'; $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]; } if ($results["result"]=="success") { echo "success"; } else { # An error occured echo "The following error occured: ".$results["message"]; } Please this is urgent. Thanks 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.