eddycjy/aliyun-api-gateway-sdk

aliyun-api-gateway-sdk

0.9.1 2017-09-28 06:23 UTC

This package is not auto-updated.

Last update: 2024-09-29 04:36:48 UTC


README

Latest Stable Version License Total Downloads

要求

  • PHP >= 5.4.0
  • Composer
  • Curl

安装

composer require eddycjy/aliyun-api-gateway-sdk

配置

使用文件

将 Env.example.php 文件复制到 Env.php

return [
    'AccessKeyId'       => '',
    'AccessKeySecret'   => '',
    'Format'            => 'json',
    'Version'           => '2016-07-14',
    'SignatureMethod'   => 'HMAC-SHA1',
    'SignatureVersion'  => '1.0'
];

使用数组

use ApiGateway\Config\ArrayConfig;
use ApiGateway\Model\ApiGroup\CreateApiGroup;
use ApiGateway\ApiService;

$config = new ArrayConfig([
    'AccessKeyId'       => '',
    'AccessKeySecret'   => '',
    'Format'            => 'json',
    'Version'           => '2016-07-14',
    'SignatureMethod'   => 'HMAC-SHA1',
    'SignatureVersion'  => '1.0'
]);

$model = new CreateApiGroup();
$model->setGroupName('Demo');
$model->setDescription('Demo-CreateApiGroup');

$serviceObj = new ApiService($model, $config);
$response   = $serviceObj->get();

使用方法

请参阅示例目录

生成

生成模型和示例

# Python 3.x
python gen.py
Please input class name: CreateApi
Please input class group: Api
Please input class property-key: GroupId
Please input class property-params: id

# input q to quit
Please input class property-key: q
  • 模型代码
namespace ApiGateway\Model\Api;

use ApiGateway\ApiModel;

class CreateApi extends ApiModel
{
    public $GroupId;

    public function setGroupId($id)
    {
        $this->GroupId = $id;

        return $this;
    }

    ...
  • 示例代码
use ApiGateway\Model\Api\CreateApi;
use ApiGateway\ApiService;

$object = new CreateApi();
$object->setGroupId($demo);
...

$serviceObj = new ApiService($object);
$response   = $serviceObj->get();

许可证

MIT