cPanel api 2 for mysql remote whitelist

May 21, 2015
5
0
1
US
cPanel Access Level
Website Owner
I have one more question, I notice in the docs that This function only returns a reason value if it failed.
I want to test my logic for failure.... is there a value that I can put in it that WILL produce a failure? Just wanted to get a failure so I can make sure that end is covered.
 
May 21, 2015
5
0
1
US
cPanel Access Level
Website Owner
Sorry for being a pest. I thought I had this all working but I have now hit another issue.

Using this...
$newdomain = "12.345.45.678";
$myemails = $xmlapi->api2_query($account, "MysqlFE", "authorizehost", array('host'=>$newdomain) );

I am able to add 12.345.45.678 to my access hosts list through the above code. I logged into cPanel to verify. But when I test the connection, I actually have no access.
If I remove the ip address manually in cPanel....then manually add it again in cPanel.....then my connection works.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,222
463
Hello,

Does it work if you use the function directly in your web browser (e.g. with the WHM API (JSON) example on the document provided earlier)?

Thank you.
 
May 21, 2015
5
0
1
US
cPanel Access Level
Website Owner
I have never tried that, and not even sure how to structure that. I have always used the method that I showed above. Does that json method still use the xmlapi.php file?

I tried looking for a basic implementation, but couldn't find an example.

This is the basic way I am doing it currently.

Code:
<?php
require_once("xmlapi.php");
$ip = 'website ip address here';
$account = 'cpanel username here';
$domain = 'mysite.com';
$passwd = 'cpanel password here';

$xmlapi = new xmlapi($ip);
$xmlapi->password_auth($account, $passwd);
$xmlapi->set_port(2083);
$xmlapi->set_output("simplexml");

$newAuthIP = "123.45.67.890";  <----- sanitized value from a form post
$myemails = $xmlapi->api2_query($account, "MysqlFE", "authorizehost", array('host'=>$newAuthIP) );
?>