承接 macloudapisdk/sdk 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

macloudapisdk/sdk

最新稳定版本:v1.0.0

Composer 安装命令:

composer require macloudapisdk/sdk

包简介

macloud.pro SDK

README 文档

README

A PHP SDK for interacting with the Macloud API. This SDK provides a simple and secure way to make RESTful API requests with built-in signature authentication.

Features

  • Support for GET, POST, PATCH, PUT, and DELETE HTTP methods
  • Built-in SHA256 signature authentication
  • RESTful API design
  • JSON request/response format
  • Configurable timeout settings
  • Optional logging support

Requirements

  • PHP >= 5.5
  • Composer

Installation

Install the package via Composer:

composer require macloudapisdk/sdk

Configuration

Before using the SDK, you need to obtain the following credentials:

  • app_id: Your application ID (contact technical support to register an account and apply for API credentials)
  • app_secret: Your application secret key (used for signature generation)
  • base_api_url: The base API URL (e.g., http://api.local.com/V4/). Contact operations staff for the specific address.

Configuration Parameters

Parameter Description Required
app_id Your assigned application ID Yes
app_secret Your assigned application secret, used for data signing Yes
base_api_url API base URL prefix Yes
timeout Request timeout in seconds (default: 10) No
log Enable SDK logging (default: false) No
logfileLinux Linux log file path (e.g., /tmp/sdk.log) No

Usage

Basic Setup

error_reporting(E_ALL);
ini_set('display_errors', 'on');

require './vendor/autoload.php';

try {
    $config = [
        'app_id'       => getenv('SDK_APP_ID'),
        'app_secret'   => getenv('SDK_APP_SECRET'),
        'base_api_url' => getenv('SDK_API_PRE'),
        // 'log'          => true,           // Enable SDK logging
        // 'logfileLinux' => '/tmp/sdk.log', // Linux log file path
    ];
    $sdk = new \macloudapisdk\Sdk($config);
    
    // Your API calls here...
    
} catch(\Exception $e) {
    var_dump("code: " . $e->getCode() . " message: " . $e->getMessage());
}

GET Request

$request = [
    'url' => 'test.sdk.get',
    'query' => [
        "page" => 1,
        "pagesize" => 10,
        "data" => [
            "name" => "name名称",
            "domain" => "baidu.com",
        ],
    ],
    'body' => [],
];
$result = $sdk->get($request);
$jsonData = json_decode($result, 1);
print_r("api: ".$request['url']."\n");
print_r("raw: ".$result."\n");
print_r($jsonData);
print_r("\n");

POST Request

$request = [
    'url' => 'test.sdk.post',
    'query' => [],
    'body' => [
        "page" => 1,
        "pagesize" => 10,
        "data" => [
            "name" => "name名称",
            "domain" => "baidu.com",
        ],
    ],
];
$result = $sdk->post($request);
$jsonData = json_decode($result, 1);
print_r("api: ".$request['url']."\n");
print_r("raw: ".$result."\n");
print_r($jsonData);
print_r("\n");

PATCH Request

$request = [
    'url' => 'test.sdk.patch',
    'query' => [],
    'body' => [
        "page" => 1,
        "pagesize" => 10,
        "data" => [
            "name" => "name名称",
            "domain" => "baidu.com",
        ],
    ],
];
$result = $sdk->patch($request);
$jsonData = json_decode($result, 1);
print_r("api: ".$request['url']."\n");
print_r("raw: ".$result."\n");
print_r($jsonData);
print_r("\n");

PUT Request

$request = [
    'url' => 'test.sdk.put',
    'query' => [],
    'body' => [
        "page" => 1,
        "pagesize" => 10,
        "data" => [
            "name" => "name名称",
            "domain" => "baidu.com",
        ],
    ],
];
$result = $sdk->put($request);
$jsonData = json_decode($result, 1);
print_r("api: ".$request['url']."\n");
print_r("raw: ".$result."\n");
print_r($jsonData);
print_r("\n");

DELETE Request

$request = [
    'url' => 'test.sdk.delete',
    'query' => [],
    'body' => [
        "page" => 1,
        "pagesize" => 10,
        "data" => [
            "name" => "name名称",
            "domain" => "baidu.com",
        ],
    ],
];
$result = $sdk->delete($request);
$jsonData = json_decode($result, 1);
print_r("api: ".$request['url']."\n");
print_r("raw: ".$result."\n");
print_r($jsonData);

Signature Algorithm

The SDK uses SHA256 signature authentication to ensure data integrity during transmission:

  • Client-side: Uses SHA256 algorithm to sign the base64-encoded parameters combined with app_secret. Each request includes the signature.
  • Server-side: Uses the same algorithm to sign the received parameters and compares it with the provided signature to verify authenticity.

This ensures that data cannot be tampered with during transmission.

Important Notes

  1. URI and Query Parameters: For all requests, URI and GET parameters are separated. For example, if the URL is https://api.local.com/V4/version?v=1, the v=1 parameter must be passed through the query parameter in the request array.

  2. Return Value: Each API call returns a raw string response. You can decode it using json_decode() to get the parsed JSON data.

  3. Error Handling: Always wrap SDK calls in try-catch blocks to handle exceptions properly.

API Response Format

The SDK returns the raw response string. The API typically returns JSON format, which can be decoded using json_decode($result, true) to get an associative array.

Support

For API credentials and base URL information, please contact:

  • Technical Support: For app_id and app_secret registration
  • Operations Staff: For the specific API base URL

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2026-01-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固