mgufrone / cpanel-php Goto Github PK
View Code? Open in Web Editor NEWCPanel/WHM API for PHP
License: MIT License
CPanel/WHM API for PHP
License: MIT License
hello , i use this code.
<?php
require_once("vendor/autoload.php");
$cpanel = new \Gufy\CpanelPhp\Cpanel([
'host' => 'https://server01.nubewww.tech:2087', // ip or domain complete with its protocol and port
'username' => 'xxxxxxxxx', // username of your server, it usually root.
'auth_type' => 'xxxxxxxxxxx', // set 'hash' or 'password'
'password' => 'xxxxxxxxxxxxxxxx', // long hash or your user's password
]);
$accounts = $cpanel->listaccts(); // it will returned as array
print_r($accounts);
and when i call from browser i recive this error.
Client error:
POST https://server01.nubewww.tech:2087/json-api/listaccts` resulted in a 403 Forbidden Access denied
response: {"cpanelresult":{"apiversion":"2","error":"Access denied","data":{"reason":"Access denied","result":"0"},"type":"text"}} (truncated...) `
Hi ,
Excuse if my question is not so good question , but I am looking a way to create DB in cpanel with api .
Can I create DB or Email account Using Cpanel-php ?
thanks
GuzzleHttp\Ring\Exception\RingException: cURL error 3: in /home/bastify/public_html/clientarea/vendor/guzzlehttp/ringphp/src/Client/CurlFactory.php:127
Stack trace:
#0 /home/bastify/public_html/clientarea/vendor/guzzlehttp/ringphp/src/Client/CurlFactory.php(91): GuzzleHttp\Ring\Client\CurlFactory::createErrorResponse(Array, Array, Array)
#1 /home/bastify/public_html/clientarea/vendor/guzzlehttp/ringphp/src/Client/CurlHandler.php(96): GuzzleHttp\Ring\Client\CurlFactory::createResponse(Array, Array, Array, Array, Resource id #501)
#2 /home/bastify/public_html/clientarea/vendor/guzzlehttp/ringphp/src/Client/CurlHandler.php(68): GuzzleHttp\Ring\Client\CurlHandler->_invokeAsArray(Array)
#3 /home/bastify/public_html/clientarea/vendor/guzzlehttp/ringphp/src/Client/Middleware.php(54): GuzzleHttp\Ring\Client\CurlHandler->__invoke(Array)
#4 /home/bastify/public_html/clientarea/vendor/guzzlehttp/ringphp/src/Client/Middleware.php(30): GuzzleHttp\Ring\Client\Middleware::GuzzleHttp\Ring\Client{closure}(Array)
#5 /home/bastify/public_html/clientarea/vendor/guzzlehttp/guzzle/src/RequestFsm.php(129): GuzzleHttp\Ring\Client\Middleware::GuzzleHttp\Ring\Client{closure}(Array)
#6 /home/bastify/public_html/clientarea/vendor/guzzlehttp/guzzle/src/Client.php(165): GuzzleHttp\RequestFsm->__invoke(Object(GuzzleHttp\Transaction))
#7 /home/bastify/public_html/clientarea/vendor/guzzlehttp/guzzle/src/Client.php(150): GuzzleHttp\Client->send(Object(GuzzleHttp\Message\Request))
#8 /home/bastify/public_html/clientarea/vendor/whmapi/src/Gufy/CpanelPhp/Cpanel.php(349): GuzzleHttp\Client->post('/json-api/lista...', Array)
#9 /home/bastify/public_html/clientarea/vendor/whmapi/src/Gufy/CpanelPhp/Cpanel.php(105): Gufy\CpanelPhp\Cpanel->runQuery('listaccts', Array)
#10 /home/bastify/public_html/clientarea/dedicated_list.php(44): Gufy\CpanelPhp\Cpanel->__call('listaccts', Array)
#11 {main}
Next GuzzleHttp\Exception\RequestException: cURL error 3: in /home/bastify/public_html/clientarea/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:51
Stack trace:
#0 /home/bastify/public_html/clientarea/vendor/guzzlehttp/guzzle/src/RequestFsm.php(103): GuzzleHttp\Exception\RequestException::wrapException(Object(GuzzleHttp\Message\Request), Object(GuzzleHttp\Ring\Exception\RingException))
#1 /home/bastify/public_html/clientarea/vendor/guzzlehttp/guzzle/src/RequestFsm.php(132): GuzzleHttp\RequestFsm->__invoke(Object(GuzzleHttp\Transaction))
#2 /home/bastify/public_html/clientarea/vendor/react/promise/src/FulfilledPromise.php(25): GuzzleHttp\RequestFsm->GuzzleHttp{closure}(Array)
#3 /home/bastify/public_html/clientarea/vendor/guzzlehttp/ringphp/src/Future/CompletedFutureValue.php(55): React\Promise\FulfilledPromise->then(Object(Closure), NULL, NULL)
#4 /home/bastify/public_html/clientarea/vendor/guzzlehttp/guzzle/src/Message/FutureResponse.php(43): GuzzleHttp\Ring\Future\CompletedFutureValue->then(Object(Closure), NULL, NULL)
#5 /home/bastify/public_html/clientarea/vendor/guzzlehttp/guzzle/src/RequestFsm.php(134): GuzzleHttp\Message\FutureResponse::proxy(Object(GuzzleHttp\Ring\Future\CompletedFutureArray), Object(Closure))
#6 /home/bastify/public_html/clientarea/vendor/guzzlehttp/guzzle/src/Client.php(165): GuzzleHttp\RequestFsm->__invoke(Object(GuzzleHttp\Transaction))
#7 /home/bastify/public_html/clientarea/vendor/guzzlehttp/guzzle/src/Client.php(150): GuzzleHttp\Client->send(Object(GuzzleHttp\Message\Request))
#8 /home/bastify/public_html/clientarea/vendor/whmapi/src/Gufy/CpanelPhp/Cpanel.php(349): GuzzleHttp\Client->post('/json-api/lista...', Array)
#9 /home/bastify/public_html/clientarea/vendor/whmapi/src/Gufy/CpanelPhp/Cpanel.php(105): Gufy\CpanelPhp\Cpanel->runQuery('listaccts', Array)
#10 /home/bastify/public_html/clientarea/dedicated_list.php(44): Gufy\CpanelPhp\Cpanel->__call('listaccts', Array)
#11 {main}
hi I just new bee here I wanted know how to use it I hit command for composer n files were get downloaded in my localhost xampp
in winodws C:\xampp\htdocs\cpanel\vendor\gufy\cpanel-php\src\Gufy\CpanelPhp this is my path to Cpanel.php
in C:\xampp\htdocs\cpanel I wrote index.php with code
'https://123.456.789.123:2087', // ip or domain complete with its protocol and port 'username' => 'root', // username of your server, it usually root. 'auth_type' => 'hash', // set 'hash' or 'password' 'password' => 'password', // long hash or your user's password ]); $accounts = $cpanel->listaccts(); // it will returned as array I gives me error Fatal error: Uncaught Error: Class 'Gufy\CpanelPhp\Cpanel' not found in C:\xampp\htdocs\cpanel\index.php:2 Stack trace: #0 {main} thrown in C:\xampp\htdocs\cpanel\index.php on line 2 how I can give reference to the CPanel.php file I tried to give full path by require once but it still gives error.Write a pice of code with example on Laravel 5.3
...
use Gufy\CpanelPhp\Cpanel;
...
$whmuser = 'root';
$hash = $this->hash; // hash on one line and correct hash
$host = $this->host; // my cpanel host
$port = $this->port; // port 2087
$cpanel = new Cpanel([
'host' => $this->host.':'.$port:,
'username' => 'root',
'auth_type' => 'hash',
'password' => $this->hash,
]);
// @todo refactor for errors
var_dump($cpanel->listaccts());
Result not json listaccts ->>
<!DOCTYPE html>\n
<html dir="ltr">\n
<head>\n
<title>hq – WebHost Manager</title>\n
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">\n
<link rel="shortcut icon" href="/cPanel_magic_revision_1448314783/favicon.ico" type="image/x-icon">\n
\n
<script src="/cPanel_magic_revision_1448314781/yui-gen/utilities_json/utilities_json.js"></script>\n
<script>\n
top._LOADAVG_TIMEOUT = 5 * 60 * 1000; //5 minutes\n
function set_last_activity() {\n
top._LAST_ACTIVITY = new Date();\n
}\n
set_last_activity();\n
\n
YAHOO.util.Event.onDOMReady( function() {\n
var these_frames = top.document.getElementsByTagName("frame");\n
for (var f=these_frames.length-1; f>-1; f--) {\n
var the_frame = these_frames[f];\n
YAHOO.util.Event.addListener( the_frame.contentWindow, "load", function() {\n
YAHOO.util.Event.addListener(this.document.body, "mousemove", set_last_activity);\n
YAHOO.util.Event.addListener(this.document.body, "keyup", set_last_activity);\n
YAHOO.util.Event.addListener(this.document.body, "keydown", set_last_activity);\n
} );\n
}\n
} );\n
</script>\n
</head>\n
\n
<frameset cols="*" frameborder="NO" border="0" framespacing="0" rows="78,*">\n
<frame src="/scripts/command?PFILE=topframe" name="topFrame" frameborder="no" scrolling="no" noresize id="topFrame"/>\n
\n
<frameset rows="*" cols="217,556*" framespacing="0" frameborder="no" border="0">\n
<frame src="/scripts/command?PFILE=command" name="commander" frameborder="no" scrolling="no" id="commander" />\n
<frame src="/scripts/command?PFILE=main" name="mainFrame" id="mainFrame" frameborder="no"/>\n
</frameset>\n
\n
\n
</frameset>\n
<noframes>WebHost Manager requires frames, but your browser does not support them.</noframes>\n
</html>\n
<!-- Web Host Manager 11.58.0.32 [10] (c) cPanel, Inc. 2016\n
http://cpanel.net/ Unauthorized copying is prohibited -->\n
Hi,
I'm trying to install Guzzle on my Application but it seems that this composer is requiring guzzle 6 but the latest version is 7.
`composer require guzzlehttp/guzzle
Using version ^7.0 for guzzlehttp/guzzle
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for guzzlehttp/guzzle ^7.0 -> satisfiable by guzzlehttp/guzzle[7.0.0, 7.0.0-beta.1, 7.0.0-beta.2, 7.0.0-rc.1, 7.0.1, 7.0.x-dev, 7.1.x-dev].
- gufy/cpanel-php v2.0.0 requires guzzlehttp/guzzle ~6 -> satisfiable by guzzlehttp/guzzle[6.5.x-dev].
- gufy/cpanel-php v2.0.0 requires guzzlehttp/guzzle ~6 -> satisfiable by guzzlehttp/guzzle[6.5.x-dev].
- gufy/cpanel-php v2.0.0 requires guzzlehttp/guzzle ~6 -> satisfiable by guzzlehttp/guzzle[6.5.x-dev].
- Conclusion: don't install guzzlehttp/guzzle 6.5.x-dev
- Installation request for gufy/cpanel-php ~2.0 -> satisfiable by gufy/cpanel-php[v2.0.0].
Installation failed, reverting ./composer.json to its original content.`
There is any plans to update this to allow the latest version of guzzle or is there a work around?
Thanks
James
Edit: So sorry - I was stupid and used the GH username instead of the Packagist one...
i am calling the cPanel mkfile api but every time it throws some errors like cURL error 28: Operation timed out after 0 milliseconds with 0 out of 0 bytes received (see http://curl.haxx.se/libcurl/c/libcurl-errors.html).
I am calling simple package functions but it throws curl errors so not getting where it comes from?
source code
$cPanel = new Cpanel([
'host' => $hostUrl ,
'username' => $username,
'auth_type' => 'hash',
'password' => $password
]);
$data = $cPanel->cpanel('Fileman', 'mkfile', $username, [
'name' => 'new_file.txt',
'path' => '/home/myfolder/public_html/',
'permissions' => '0777',
]);
print_r($data);
Please help me to resolve or any correction?
Hi! I'm trying to use this in Symfony2 but I got an error on the trait.
Case mismatch between loaded and declared class names: Gufy\CpanelPhp\CpanelShortcuts vs Gufy\CpanelPhp\cPanelShortcuts
Symfony2 seems to be strict on the name case.
Hello,
I am trying the example:
$cpanel = new \Gufy\CpanelPhp\Cpanel([
'host' => 'https://xx.xx.xx.xx:2087', // ip or domain complete with its protocol and port
'username' => 'root', // username of your server, it usually root.
'auth_type' => 'password', // set 'hash' or 'password'
'password' => 'my_password', // long hash or your user's password
]);
$accounts = $cpanel->listaccts(); // it will returned as array
when i var_dump the $accounts i get the following:
Client error response [url] https://xx.xx.xx.xx:2087/json-api/listaccts [status code] 403 [reason phrase] Forbidden Access denied
What am i doing wrong?
Is there something else i should do?
Thanks
you should replace
composer require gufy/cpanel-whm:dev-master
with
composer require gufy/cpanel-php:dev-master
Hello,
How call WHM API 1? I can call WHM API 0 (Deprecated), UAPI and cPanel API 2, but not WHM API 1. How to call it? https://documentation.cpanel.net/display/SDK/Guide+to+WHM+API+1
Amazing component, only low doc.
Exists an extended docs, apidoc based em php doc or similary?
When I run your code against our cPanel server I receive an error indicating that the server has returned a 403 Forbidden for URL https://hostname.domain.com:2087/json-api/listaccts
Shouldn't the URL called be the code have a security token of the form cpsess###### in it somewhere?
What minimum php version to use please?
I has get error when dumpzone.
in Cpanel.php line 343
at HandleExceptions->handleError('8', 'Undefined offset: 0', '/home/nginx/domains/xxx/public/vendor/gufy/cpanel-php/src/Gufy/CpanelPhp/Cpanel.php', '343', array('action' => 'dumpzone', 'arguments' => array('domain' => 'xxx.com'), 'host' => 'https://10.0.0.3:2087', 'client' => object(Client))) in Cpanel.php line 343
Resolve:
change
'query' => count($arguments) > 1 ? $arguments : $arguments[0],
to
'query' => $arguments,
Please check it :)
I want to create the security token for a cpanel user token "cpsessXXXXXXXXXX" using the WHM API Token.
The API token privilege many operation and on of the Operation is, "create-user-session".
Is this Repo has any way to do this?
Hi,
Is it possible to get emails from an account?
Laravel 7.x
Example: [email protected]
Hi,
I want only export list of all domain on whm, can someone guide me how to use?
Tanks very much..
The "delsubdomain" function is not working.
Other than that the work is very good.
However I have a project that I need to implement with this function.
Can you help me?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.