定制 fortisx/sdk 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fortisx/sdk

最新稳定版本:v0.1.0

Composer 安装命令:

composer require fortisx/sdk

包简介

Fortisx PHP SDK

README 文档

README

This guide explains how to interact with the API using the PHP client.

Installation

composer require fortisx/sdk

Initialization

require 'vendor/autoload.php';

use FortisX\SDK\API;

$api = new API('YOUR_API_KEY');

Constructor options

Name Type Default Description
$apiKey string API key used for authorization
$baseUrl string https://api.fortisx.fi/v1 Override if using a custom environment
$timeout int 10 Request timeout in seconds

Methods

Method Arguments Returns Description
get(string $endpoint, array $params = []) endpoint path, optional params array Performs a GET request
post(string $endpoint, array $data = []) endpoint path, optional data array Performs a POST request
put(string $endpoint, array $data = []) endpoint path, optional data array Performs a PUT request
delete(string $endpoint) endpoint path array Performs a DELETE request

All requests use GuzzleHttp\Client and automatically include the following headers:

[
  'Authorization' => "Bearer {$apiKey}",
  'Accept' => 'application/json'
]

Error Handling

When a network or server error occurs, an exception of type APIError is thrown.

namespace FortisX\SDK;

class APIError extends \Exception {
    public int $status;
    public array $details;

    public function __construct(string $message, int $status = 0, array $details = []) {
        parent::__construct($message);
        $this->status = $status;
        $this->details = $details;
    }
}
Field Type Description
$message string Short description of the error
$status int HTTP status code
$details array Full response body if available

Example:

use FortisX\SDK\API;
use FortisX\SDK\APIError;

$api = new API('demo-key');

try {
    $res = $api->get('ping');
    print_r($res);
} catch (APIError $err) {
    echo "API error [{$err->status}]: {$err->getMessage()}";
} catch (Exception $e) {
    echo "Unexpected error: {$e->getMessage()}";
}

Example: /ping Endpoint

require 'vendor/autoload.php';

use FortisX\SDK\API;

$api = new API('demo-key');
$response = $api->get('ping');

print_r($response); // ['status' => 'ok']

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-08