简体   繁体   中英

Changing Email Passwords With cPanel XML API in PHP

I've been jogging my mind on how to enable my users to change their passwords using the cPanels XML API. I've googled, played with example code, and could not find anything that remotely works. Can someone please tell me what I'm doing wrong? Thanks!

require_once('../includes/xmlapi.php');

$ip = '127.0.0.1';
$root_pass = 'secret';

$account = 'accountna';
$email_account = $_POST['email'];
$email_domain = "mydomain.com";

$xmlapi = new xmlapi($ip);
$xmlapi->password_auth("root",$root_pass);
$xmlapi->set_debug(1);

$args = array(
  'domain'=>$email_domain, 
  'email'=>$email_account
);


if ($xmlapi->api2_query($account, "Email", "passwdpop", array( 'domain' => "domain name", 'email' => "user name", 'password' => "new password") )) {
    echo "Success!";
};

you neet to set port! before password_auth

$xmlapi->set_port ( 2083 );
$xmlapi->password_auth("root",$root_pass);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM