Jump to content

Error while using API:Module change password


tobaniyi

Recommended Posts

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated