Provide support for LivePHP<\/li>\n<\/ul>\nBecause LivePHP and XML-API work on two different query mechanisms (file sockets and HTTP, respectively) it was immediately apparent that the code responsible for transmitting and receiving the server response would need to be abstracted.<\/p>\n
We also had to consider that the Public API, XML-API, and LivePHP interfaces defined their own set of query methods. This meant that any instance of the client object would need to be smart enough to know about each interfaces’ methods, understand their context, and validate each methods’ arguments.<\/p>\n
The most direct solution would have been to lump all of the query calls together in one class. However, this solution would have put us back to square one if a new interface or cPanel service were to be introduced. Instead, we made a series of inherited models that would function ‘under the hood,’ while the ‘top’ would be a customizable object that could be tailored as necessary.<\/p>\n
Long story short, about 2000 lines into it, we realized that this was no longer a client but a full-fledged library \u2014 a group of components that are (mostly) decoupled. The result being that any one or more components can be used to build an entirely different client or application. Thus, the cPanel PHP Library was born.<\/p>\n
The README.markdown file in the repo (also in the PEAR package) offers a good summarization of what is included in the distribution as well as an introduction to the cPanel PHP Library and PublicAPI. Please take the time to read that file and checkout the *Examples\/* directory in the distribution.<\/p>\n
As an example, here is a little script I wrote while answering a quick forum post related to Analog Stats queries via API1 and API2: \narray( \n'whm' => array( \n'host'=>'127.0.0.1', \n'user'=>'root', \n'hash'=>$hash, \n), \n), \n); \n$cp = Cpanel_PublicAPI::getInstance(); \n\/\/ just a quick poll of what cPanel version I'm running \n$response = $cp->whm_api('version'); \necho \"Version: {$response->version}n\"; \n\/\/ Test the output of API2 Stats::listanalog \n\/\/ call should produce a list of domains that have stats \n$mf = array( \n'module' => 'Stats', \n'function' => 'listanalog', \n'user' => 'cppirum', \n); \n$api2_list = $cp->cpanel_api2_request('whostmgr', $mf); \necho \"List from API2 Stats::listanalogn\"; \n\/** \n* For debugging I could just dump the \"array\" format \n* var_dump ($api2_list->getResponse('array')); \n* \n* But I'd rather have a nice loop on the object \n*\/ \nforeach ( $api2_list->cpanelresult->data as $stat_holder) { \necho \"tDomain '{$stat_holder->domain}' has stats.n\"; \n} \necho \"n\"; \n\/\/ Same thing here, only we'll look at API1 Stats::analoglist, which generates HTML \n$mf = array( \n'module' => 'Stats', \n'function' => 'analoglist', \n'user'=>'cppirum', \n); \n\/\/ This API call requires a domain \n$args = array('pear.cppirum.net'); \n$api1_list = $cp->cpanel_api1_request('whostmgr', $mf, $args); \necho \"list from API1 Stats::analoglistn\"; \n$html = $api1_list->data->result; \n$xml = '' . trim($html) . ''; \n$sxml = simplexml_load_string($xml); \nforeach ($sxml->a as $url) { \n$attributes = $url->attributes(); \necho \"tStats for {$url} can be found at 'https:\/\/{$args[0]}:2083{$attributes['href']}'.n\"; \n} \necho \"n\"; \n?> \n<\/code><\/p>\nAs you can see, I used the the whm_api(), cpanel_api1_request(), and cpanel_api2_request() query methods of the PublicAPI interface. The arguments for each of those methods are the same as in the Perl PublicAPI client.<\/p>\n
Download it and give it whirl. This is BETA software so you may encounter some quirky behavior. If you experience any problems, please let use know by using the [github issue tracker](http:\/\/github.com\/CpanelInc\/publicapi-php\/issues). There are several features within the library that we hope to refine, as it matures to a STABLE release over the next several months.<\/p>\n
In the coming days, we hope to provide more detailed documentation on sdk.cpanel.net<\/a> concerning PublicAPI (Perl and PHP) and the cPanel PHP library. In the meantime, you can checkout the POD (Perl) and DocBlock (PHP) documentation that’s included in the code.<\/p>\nRegards & Happy Coding!<\/p>\n","protected":false},"excerpt":{"rendered":"
We are pleased to announce that our PublicAPI PHP client is ready! This API query client is the sibling to Cpanel::PublicAPI that was announced last month. You can download the PublicAPI PHP client at our github repository as well as the new cPanel PEAR channel. One of the key distinctions of the PublicAPI PHP client […]<\/p>\n","protected":false},"author":77,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[49],"tags":[],"class_list":["post-78","post","type-post","status-publish","format-standard","hentry","category-products"],"acf":[],"yoast_head":"\n
BETA Release of PublicAPI PHP, the cPanel PHP Library, and cPanel PEAR | cPanel<\/title>\n
\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n