Skip to content

Commit

Permalink
Added Example Controller
Browse files Browse the repository at this point in the history
  • Loading branch information
rnavarro committed Sep 9, 2009
1 parent a54f11f commit 2513ed7
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions example_controller.php
@@ -0,0 +1,55 @@
<?php
class ExamplesController extends AppController {
var $name = 'Examples';
var $uses = array();
var $components = array('CpanelApi');

function api() {
$this->CpanelApi->host = '';

// sets the port to communicate on (defaults to 2086)
// If just a user (not a reseller or admin)
// you probably want to use ports 2082 or 2083
// otherwise use the WHM ports, 2086 or 2087
$this->CpanelApi->set_port(2082);

// Use an API Hash
$this->CpanelApi->hash = '';
// or Credentials
$this->CpanelApi->username = '';
$this->CpanelApi->password = '';

// Toggles debug flag
$this->CpanelApi->debug = TRUE;
// Toggles raw xml output flag, only valid if debug is TRUE
$this->CpanelApi->rawXML = TRUE;

// Example 1 - pull bandwidth and disk usage statistics for cpanel user
$result = $this->CpanelApi->api2_query(
'cpanel_user', // Change me
'StatsBar',
'stat',
array(
'display' => 'diskusage|bandwidthusage',
'infinitylang' => '1',
'rawcounter' => 'mainstats'
)
);

if($result) {
debug($result);
} else {
debug($this->CpanelApi->error);
}

// Example 2 - get list of available api commands
$result = $this->CpanelApi->applist();

if(!$this->CpanelApi->error) {
debug($result);
} else {
debug($this->CpanelApi->error);
}
}
}
?>

0 comments on commit 2513ed7

Please sign in to comment.