I've noticed that it seems (my assumption) like you are connecting as a cPanel user for password_auth() and then connecting as root for the query. That won't work. You can connect as root for password_auth() and then have $user set to a cPanel user for api1_query() but not the other way around.
If you want to connect as the user for password_auth(), you should specify the cPanel port in your xmlapi object like so:
Code:
$xmlapi->set_port('2083');
and you need to specify the domain owner for any api1/api2 queries, regardless of which user you are using to authenticate:
Code:
$xmlapi->api1_query($domain_owner, "Email", "addpop", $params)
As far as the SSL error goes, this could be a number of things. The XMLAPI library is using curl to connect to your cPanel/WHM server and the response it is getting back is not what curl is expecting. You should test to see if you can connect via command line curl to your cPanel/WHM server (this should return some JSON with access denied):
Code:
curl -k "https://hostname:2087/json-api/cpanel?user=username&cpanel_jsonapi_module=Email&cpanel_jsonapi_func=addpop&cpanel_jsonapi_version=2&domain=mbracecloud.com&email=hello&password=hello0513"a=250"
If you're not getting JSON back, then curl is having issues connecting to cPanel/WHM and you may have an invalid SSL cert, or ports 2083/2087 may be blocked, or you're connecting to a machine that isn't broadcasting SSL, or some other issue is preventing a SSL connection.
Try connecting with openssl to see if you get any errors:
Code:
openssl s_client -connect hostname:2087
Also try curl's verbose mode on the headers:
Code:
curl --verbose -i -k "https://hostname:2087/json-api/cpanel?user=username&cpanel_jsonapi_module=Email&cpanel_jsonapi_func=addpop&cpanel_jsonapi_version=2&domain=mbracecloud.com&email=hello&password=hello0513"a=250"
It should also be noted that in API1, you shouldn't pass the argument names in the params array. Instead, you just need to present the arguments as a properly ordered array of values like so:
Code:
$params = array('hello','hello05013','250','mbracecloud.com'); //(email,password,quota,domain)
Since it's easier to visually debug associative arrays (and because it's always best to use the newest API), you should use API2 rather than API1:
Code:
$xmlapi->api2_query($domain_owner, "Email", "addpop", $params)