ycloud/ycloud-sdk-php

PHP YCloud SDK

v1.14.0 2024-09-13 07:13 UTC

README

YCloud API 围绕 REST 组织。我们的 API 设计为具有可预测的资源导向 URL,返回 JSON 响应,并使用标准的 HTTP 响应代码和动词。

安装与使用

要求

PHP 7.4 及以上版本。也应与 PHP 8.0 兼容。

Composer

要使用 Composer 安装绑定,请在您的项目目录中运行以下命令

composer require ycloud/ycloud-sdk-php

或者,将以下内容添加到 composer.json

{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://github.com/ycloud-developers/ycloud-sdk-php.git"
    }
  ],
  "require": {
    "ycloud/ycloud-sdk-php": "*@dev"
  }
}

然后运行 composer install

入门

请按照 安装过程 进行操作,然后运行以下命令

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



// Configure API key authorization: api_key
$config = YCloud\Client\Configuration::getDefaultConfiguration()->setApiKey('X-API-Key', 'YOUR_API_KEY');


$apiInstance = new YCloud\Client\Api\BalanceApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client(),
    $config
);

try {
    $result = $apiInstance->retrieve();
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling BalanceApi->retrieve: ', $e->getMessage(), PHP_EOL;
}

API 端点

所有 URI 都是相对于 https://api.ycloud.com/v2

模型

授权

api_key

  • 类型: API密钥
  • API密钥参数名称: X-API-Key
  • 位置: HTTP头