petebishwhip/whmcsapi

This package is abandoned and no longer maintained. No replacement package was suggested.

This project is simple. It is an object-oriented library of the WHMCS API functions.

1.0.0-alpha.2 2020-03-09 19:50 UTC

This package is auto-updated.

Last update: 2022-11-28 01:17:52 UTC


README

Build Status Mergify Status

This project is simple. It is an object-oriented library of the WHMCS API functions. To use this wrapper is simple.

Requirements

  • PHP 7.3 (It may work on lower. I only test on PHP 7.3 due to dev-dependencies)
  • Composer
  • WHMCS Installation (and License!) - Buy Here

Usage

First, import the library. As WHMCSAPI is currently in alpha/beta status, set the minimum version to 1.0@alpha:

composer require PeteBishwhip/WHMCSAPI:"^1.0@alpha"

After you have imported the library, initialize the wrapper by providing three values.

Variable Description
$apiIdentifier Your API Identifier
$apiSecret Your API Secret
$whmcsUrl Your WHMCS URL (e.g. https://example.com/whmcs/)
use WHMCSAPI\WHMCSAPI;

// $whmcsApi = new WHMCSAPI('abc123', '123cba', 'https://example.com/whmcs/');
$whmcsApi = new WHMCSAPI($apiIdentifier, $apiSecret, $whmcsUrl);

After initializing the library, use command to set the API command you want to use:

try {
    $whmcsApi->command('AcceptOrder');
} catch (\WHMCSAPI\Exception\FunctionNotFound $e) {
    // Perform error handling here
    // You can retrieve the error with
    // $e->getMessage();
}

If the command is not available, a \WHMCSAPI\Exception\FunctionNotFound exception will be thrown to allow for catching errors. If you want to perform all actions in the same try/catch, catch WHMCSAPI\Exception\Exception. All exceptions extend from this.

From there, you can set any variables as documented in the WHMCS Developer Documentation:

$whmcsApi->orderid = 25;

When ready, you can finally execute the command:

$result = $whmcsApi->execute();

Contributing

Please see CONTRIBUTING.md for advice and guidance.