cPanel Blog

October 2009

XML API PHP class version 1.0

| No TrackBacks

Some of the reasons why there hasn’t been many updates lately include our cPanel conference, the cPanel/WHM 11.25.0 release, and the release of the XML-API PHP class 1.0.  If you are not familiar with the XML-API PHP class, it makes interacting with the XML-API much more simple by implementing functions that allow you to call your remote cPanel server without ever having to touch cURL or simplexml.  This works by implementing a function for every XML-API call.  For example:


$xmlapi = new xmlapi($ip, “root”, $root_pass);
$zones = $xmlapi->listzones();

The code above will make $zones a simplexml object that contains all of the zones on the server.  This combined with proper data handling (encoding), the ability to return associative arrays, simplexml objects, raw JSON or raw XML makes developing PHP applications for the XML-API rather simple.

The biggest change in this version is the fact that the class is full documented, allowing you to access a quick reference for looking up these functions and how they work.

This version is a complete re-write from the previous version.  The (partial) change log is below:

 

  • Added in 11.25 functions
  • Changed the constructor to allow for either the "DEFINE" config setting method or using parameters
  • Removed used of the gui setting
  • Added fopen support
  • Added auto detection for fopen or curl (uses curl by default)
  • Added ability to return in multiple formats: associative array, simplexml, xml, json
  • Added PHP Documentor documentation for all necessary functions
  • Changed submission from GET to POST
  • Change api1 and api2 query to use XML-API fast mode
  • added authentication failure detection for 11.24
  • add array checking where array parameters are taken in

If you are interested in working with the XML-API PHP Class, you can download it here.  If you want to provide feedback, bugs, or comments you can do so from the developer’s discussion forum

It should be noted that this is not an supported class, but rather released as reference code.  If you need assistance with the class, the forum is the proper place to ask for help.

Spotlight On: WHM Plugins & cPanel PHP

| No TrackBacks

If you haven’t noticed, we’ve been working on overhauling our development documentation pretty heavily.  We have a ton of great ways to integrate with cPanel but until recently, no information on how to use them.  Starting this week, every week I will be posting about what new articles we’ve added to this documentation along with why you should know about these features.

Past couple of weeks I personally have been trying to focus on how to extend the cPanel interface.  How to add new interfaces to it and different ways of creating these interfaces.  Specifically I have added two sections; WHM Plugins and cPanel PHP.

WHM Plugins
- These are extension to the cPanel interface and probably about the most straight-forward integration that cPanel provides.  These are just regular CGI scripts with a couple of comments to control how they work

cPanel PHP - In this document we talk about how to use PHP in the cPanel interface along with how PHP and cpanel’s APIs can live together in a single file.  This is also another “simple” form of integration that is worth a read for anyone looking to develop custom applications for their users to use.