mikejs Posted August 3, 2011 Share Posted August 3, 2011 Hi I have just moved from another billing system over to WHMCMS and I am very pleased so far. I have created a demo account in cpanel I have created a hidden package via WHMCMS I have then created a demo customer and registered the packagage I have two scripts I want to run one will delete the demo account the other with re-create it this is the delete script <?php $url = "http://www.***************/includes/api.php"; # URL to WHMCS API file $whmcs_admin = "*******"; # Admin username goes here $whmcs_pw = "*******"; $demo_account_id = "1"; $postfields["username"] = $whmcs_admin; $postfields["password"] = md5($whmcs_pw); $postfields["action"] = "serverterminate"; $postfields["accountid"] = "1"; $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") { print "Demo account terminated"; } else { # An error occured $error_msg = $results["message"]; when I run this file I get Authentication Failed error I have added my servers ip to the allowed ip list any idea why this is not working? thanks Mike 0 Quote Link to comment Share on other sites More sharing options...
RenatoMN Posted August 4, 2011 Share Posted August 4, 2011 Did you enabled API access to the admin account you're using in the script? 0 Quote Link to comment Share on other sites More sharing options...
mikejs Posted August 4, 2011 Author Share Posted August 4, 2011 Thanks for the reply I found another post that explained how to create an api admin account. now when I run the script I get Command Not Found error 0 Quote Link to comment Share on other sites More sharing options...
RenatoMN Posted August 4, 2011 Share Posted August 4, 2011 According to http://docs.whmcs.com/API:Module_Terminate the action should be: $postfields["action"] = "moduleterminate"; 0 Quote Link to comment Share on other sites More sharing options...
mikejs Posted August 4, 2011 Author Share Posted August 4, 2011 thanks for the reply I changed the code and now I get An unknown error occured so I guess its a no go. 0 Quote Link to comment Share on other sites More sharing options...
RenatoMN Posted August 5, 2011 Share Posted August 5, 2011 Did you check if the accountid = 1 is actually there on the server?! 0 Quote Link to comment Share on other sites More sharing options...
mikejs Posted August 5, 2011 Author Share Posted August 5, 2011 Did you check if the accountid = 1 is actually there on the server?! Which table is this I asumed it was for the admin tables so id=1 ?? 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.