1

Recently I am trying to create an database and its user with help of this class. And I tried the following code.

include_once("xmlapi.php"); // this can be downlaoded from https://github.com/CpanelInc/xmlapi-php/blob/master/xmlapi.php

$ip = getenv('REMOTE_HOST');
$root_pass = getenv('REMOTE_PASSWORD');
$xmlapi = new xmlapi($ip);
$xmlapi->password_auth("root",$root_pass);
$xmlapi->set_debug(1);
$acct = array( username => "someuser", password => "pass123", domain => "exampledoamin.com");  // here i used my domain name. 
print $xmlapi->createacct($acct);

but its return the following error.

Fatal error: Uncaught exception 'Exception' with message 'No host defined' in

And its showing error when i require the master file. What's wrong in my code. I couldn't find the bug. Am I missed anything.

Edit:

Var_dump($ip);

bool(false);

4

1 回答 1

0

最后我通过重写代码解决了这个问题。就这个。

include_once("xmlapi.php"); 

$ip = "hostname";

$xmlapi = new xmlapi($ip);
$xmlapi->password_auth("cpanel_user-name","Password");
$xmlapi->set_port(2083);
$xmlapi->set_debug(1);

print $xmlapi->get_host();

比,它与主机连接。

于 2015-12-22T07:44:32.470 回答