Hi there,
I have a Gravity Form on a Wordpress website. The goal is once it is filled out, it will create a cPanel account (along with other things).
I'm using gform_confirmation to hook into the form data.
Everything is working until I call WHM API 1 - Create an account. Then I get the error {"cpanelresult":{"apiversion":"2","error":"Access denied","data":{"reason":"Access denied","result":"0"},"type":"text"}}.
The specific code is below:
I've double check the authorization token and even increased permissions to everything to rule that out as a problem.
I've tried on two different servers and both are giving the same problem.
I've tried with an api token I know works from the command line.
I've copied and pasted the code from Guide to API Authorization, then edited it to my values. Still same issue.
I've printed out $url and $header to make sure the correct values are there.
I've tried the curl to PHP converter. Still same issue.
Anyone have a suggestion on what I am doing wrong?
I have a Gravity Form on a Wordpress website. The goal is once it is filled out, it will create a cPanel account (along with other things).
I'm using gform_confirmation to hook into the form data.
Everything is working until I call WHM API 1 - Create an account. Then I get the error {"cpanelresult":{"apiversion":"2","error":"Access denied","data":{"reason":"Access denied","result":"0"},"type":"text"}}.
The specific code is below:
PHP:
public function create_account($cp_user) {
print 'Creating cPanel Account...';
$this->cp_user = $cp_user;
$url = "$this->server_address:2087/json-api/createacct?api.version=1&username=$this->cp_user&domain=$this->domain&contactemail=$this->email&dkim=1&frontpage=0&hasshell=1&language=en&owner=root&mxcheck=auto&owner=root&password=$this->password&plan=Inception";
$header[0] = "Authorization: whm root:$this->server_auth";
$ch = curl_init();
$options = array(
CURLOPT_URL => $url,
URLOPT_RETURNTRANSFER => 1,
CURLOPT_HTTPHEADER => $header);
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch);
}
curl_close($ch);
}
I've tried on two different servers and both are giving the same problem.
I've tried with an api token I know works from the command line.
I've copied and pasted the code from Guide to API Authorization, then edited it to my values. Still same issue.
I've printed out $url and $header to make sure the correct values are there.
I've tried the curl to PHP converter. Still same issue.
Anyone have a suggestion on what I am doing wrong?