PHP code example of fintech-systems / whmcs-php-api
1. Go to this page and download the library: Download fintech-systems/whmcs-php-api library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
fintech-systems / whmcs-php-api example snippets
return [
'url' => env('WHMCS_URL'),
'api_identifier' => env('WHMCS_API_IDENTIFIER'),
'api_secret' => env('WHMCS_API_SECRET'),
'limitnum' => env('WHMCS_LIMITNUM', 10000),
'debug' => env('WHMCS_DEBUG'),
];
test('it can create a new client in WHMCS', function () {
$customfields = base64_encode(
serialize(
[
8 => '50-100',
]
)
);
$client = [
'firstname' => $this->faker->firstName,
'lastname' => $this->faker->lastName,
'email' => $this->faker->email,
'address1' => $this->faker->numberBetween(1, 100).' '.$this->faker->streetName,
'address2' => $this->faker->secondaryAddress,
'city' => $this->faker->city,
'state' => $this->faker->state,
'postcode' => $this->faker->postcode,
'country' => config('whmcs.default_country'),
'phonenumber' => $this->faker->phoneNumber,
'password2' => bin2hex(random_bytes(8)),
'customfields' => $customfields,
];
$result = Whmcs::addClient($client);
expect($result)->toHaveKey('result')
->and($result['result'] == 'success');
})->only();
use WHMCS\Database\Capsule;
if (!defined("WHMCS"))
die("This file cannot be accessed directly");
try {
$client = Capsule::table('tblclients')
->where("phonenumber", $_REQUEST['phonenumber'])
->first();
if ($client) {
$apiresults = [
"result" => "success",
"message" => "ok",
'clientid' => $client->id,
];
} else {
$apiresults = [
"result" => "error",
"message" => "not found",
];
}
} catch (Exception $e) {
$apiresults = ["result" => "error", "message" => $e->getMessage()];
}
use Eugenefvdm\WhmcsApi\WhmcsApi;
(__DIR__);
$dotenv->load();
$server = [
'url' => env('WHMCS_URL'),
'api_identifier' => env('WHMCS_API_IDENTIFIER'),
'api_secret' => env('WHMCS_API_SECRET'),
];
$api = new WhmcsApi($server);
$result = $api->getClients();
Whmcs::setServer([
'url' => env('WHMCS_URL2'),
'api_secret' => env('WHMCS_API_SECRET2'),
'api_identifier' => env('WHMCS_API_IDENTIFIER2'),
])
$newServiceId = 5;
$api = new WhmcsApi;
$api->changePackage($newServiceId);
public function setServer($server) {
$this->url = $server['url'];
$this->api_identifier = $server['api_identifier'];
$this->api_secret = $server['api_secret'];
}
$newServiceId = 5;
WhmcsApi::changePackage($newServiceId);
bash
php artisan vendor:publish --provider="Eugenefvdm\Whmcs\WhmcsServiceProvider"
bash
#!/bin/bash
echo "Present Working Directory:"
pwd
echo "Copying $1 to WHMCS install directory"
cp