Reputation: 852
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)
;
Upvotes: 1
Views: 632
Reputation: 852
finally I solved the problem by rewriting the code. Here is it.
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();
Than, its connected with the host.
Upvotes: 0