Skip to content

PeteBishwhip/WHMCSAPI

master
Switch branches/tags
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

WHMCSAPI - The WHMCS, PHP API Wrapper

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.

About

A PHP API Wrapper for the default WHMCS API commands

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages