2013-07-31 123 views
1

我一直在慢慢思索如何讓用戶使用cPanels XML API更改密碼。我用Google搜索了一下,用示例代碼來玩,但找不到任何遠程工作的東西。有人可以告訴我我做錯了什麼嗎?謝謝!在PHP中使用cPanel XML API更改電子郵件密碼

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!"; 
}; 

回答

0

你需要設置端口! 之前password_auth

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