UAPI PHP creating a ftp account ... There was a problem fetching the env variablecontaining the path to the socket
Hello all,
I am very new using the cpanel/whm APIs and I am having an issue just getting the library to load.
Here is the basic code I am trying:
But it only returns an error 500 and this is the error log:
I would really like to use the built-in PHP class rather than rely on curls to the cpanel session URL stuff as this is way cleaner for what I will end up needing to do for managing FTP accounts automatically. Thanks, Kyle Edit: As of right now, this is the only solution I've found even though its not ideal: N1ghteyes/cpanel-UAPI-php-class
uapi(
'Ftp', 'add_ftp',
array(
'user' => 'xxxxx@XXXXXX.ca',
'pass' => '1234567890qwertyuiopxx',
'quota' => '100',
)
);But it only returns an error 500 and this is the error log:
[08-Jan-2020 09:29:41 UTC] PHP Fatal error: Uncaught Error: Class 'CPANEL' not found in /home/xxxxxxxxxx/ftp_account_test.php:4
Stack trace:
#0 {main}
thrown in /home/xxxxxxxxxx/ftp_account_test.php on line 4
[08-Jan-2020 09:36:48 UTC] PHP Fatal error: Uncaught RuntimeException: There was a problem fetching the env variablecontaining the path to the socket in /usr/local/cpanel/php/cpanel.php:146
Stack trace:
#0 /home/xxxxxxxxxx/ftp_account_test.php(4): CPANEL->__construct()
#1 {main}
thrown in /usr/local/cpanel/php/cpanel.php on line 146I would really like to use the built-in PHP class rather than rely on curls to the cpanel session URL stuff as this is way cleaner for what I will end up needing to do for managing FTP accounts automatically. Thanks, Kyle Edit: As of right now, this is the only solution I've found even though its not ideal: N1ghteyes/cpanel-UAPI-php-class
-
Hello, Have you taken a look at the guide to testing custom code? You can find it here: Guide to Testing Custom Code - Developer Documentation - cPanel Documentation 0 -
Hello, the above code is not custom it is the example from your UAPI: UAPI Functions - Ftp::add_ftp - Developer Documentation - cPanel Documentation I resume the issue is some kinda of permission problem. But I am very unfamiliar with the CPANEL UAPI and do not know where to start looking. I am running this script from a web request. 0 -
Hey @Mr.Newlove , The LiveAPI system will only run locally on the server. In order to call the API remotely, you'll need an API Token for authentication that should be contained in the header of an HTTP request. If you want to make the request as root masquerading a cPanel user, use a cPanel API Token. An example of an HTTP request and header using an API token can be found 0
Please sign in to leave a comment.
Comments
3 comments