silinternational/apiaxle-sdk-php

ApiAxle API 的 PHP 客户端

2.0.1 2023-06-14 15:38 UTC

This package is auto-updated.

Last update: 2024-09-14 18:09:50 UTC


README

此库为 ApiAxle API 提供了覆盖。它使用 Guzzle 和 Guzzle Services 构建以提高开发和维护的简便性。

Coverage Status Build Status

安装

使用 composer 安装

composer require silinternational/apiaxle-sdk-php:^1.0.0

使用方法

每个资源都有自己的类

  • API:Apiaxle\Api
  • 密钥:Apiaxle\Key
  • 密钥库:Apiaxle\Keyring

对于每个资源,您通过传递包含以下参数至少的配置数组来实例化对象

  • endpoint:您的 ApiAxle 安装的端点 URL
  • key:用于验证 ApiAxle API 的 API 密钥
  • secret:用于计算 API 签名的共享密钥

示例

use Apiaxle\Api;

$client = new Api([
    'endpoint' => 'https://apiaxle.api.mydomain.com',
    'key' => 'abc123',
    'secret' => 'abcdefghijklmnopqrstuvwxyz1234567890',
]);

创建 API

use Apiaxle\Api;

$client = new Api([
    'endpoint' => 'https://apiaxle.api.mydomain.com',
    'key' => 'abc123',
    'secret' => 'abcdefghijklmnopqrstuvwxyz1234567890',
]);

$api = $client->create([
    'id' => 'myapi',
    'endpoint' => 'myapiendpoint.com',
    'protocol' => 'https',
    'strictSSL' => true,
    'defaultPath' => '/api',
]);

print_r($api);

输出

Array
(
    [statusCode] => 200
    [meta] => Array
        (
            [version] => 1
            [status_code] => 200
        )

    [results] => Array
        (
            [protocol] => https
            [apiFormat] => json
            [endPointTimeout] => 2
            [disabled] => false
            [strictSSL] => true
            [sendThroughApiKey] => false
            [sendThroughApiSig] => false
            [endPoint] => myapiendpoint.com
            [createdAt] => 1389915291013
            [tokenSkewProtectionCount] => 3
            [hasCapturePaths] => false
            [allowKeylessUse] => false
            [keylessQps] => 2
            [keylessQpd] => 172800
            [updatedAt] => 1427892638934
        )

)

许可证

MIT 许可证

版权所有 (c) 2016 SIL International

特此授予任何获取此软件及其相关文档副本(“软件”)的人免费使用该软件的权利,不受任何限制,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或出售软件副本的权利,并允许向提供软件的人授予此类权利,但前提是遵守以下条件

上述版权声明和本许可声明应包含在软件的副本或主要部分中。

软件按“原样”提供,不提供任何明示或暗示的保证,包括但不限于适销性、适用于特定目的和无侵权性的保证。在任何情况下,作者或版权所有者不应对任何索赔、损害或其他责任负责,无论是在合同、侵权或其他行为中产生的,是否与软件或其使用或其他交易有关。