i4e/php-whmcs-api

php whmcs api 客户端

dev-main 2022-01-10 20:22 UTC

This package is auto-updated.

Last update: 2024-09-11 01:51:13 UTC


README

简单且兼容PSR7的WHMCS API客户端

安装

Composer

$ composer require "i4e/php-whmcs-api" "guzzlehttp/guzzle:^7.2" "http-interop/http-factory-guzzle:^1.0"

系统需求

此包需要

  • PHP ^7.4 | ^8.0
  • PHP 扩展 curljsonmbstring

用法

初始化客户端

客户端的基本初始化。

<?php
require_once __DIR__ . '/vendor/autoload.php';

$client = new \i4e\WhmcsApi\Client();
// Auth Credentials with identifier and secret
$client->authenticate('your_identifier', 'your_secret', \i4e\WhmcsApi\Client::AUTH_API_CREDENTIALS);
// Login Credentials with Username and Password (without md5)
$client->authenticate('your_username', 'your_password', \i4e\WhmcsApi\Client::AUTH_LOGIN_CREDENTIALS);
$client->url('http://<your_whmcs_instance_url>');

示例

获取客户端

$client->client()->getClients(['search' => 'firstname']);

获取所有订单

$client->orders()->getOrders();

调用自定义API路由

如果你的WHMCS实例包含自定义API路由,您也可以不扩展代码来调用它们。

$parameters = ['foo' => 'bar'];
$client->custom()->yourCustomApiName($parameters);

免责声明

如果您正在使用此客户端,请参考 WHMCS开发者 页面上的文档。API的文档在某些地方很不完整,在某些情况下文档质量可疑。

许可协议

此包在MIT许可下发布。