全部产品

PHP SDK 示例

安装 SDK

PHP SDK 使用说明:https://help.aliyun.com/document_detail/53111.html

调用 Codeup API

以 CreateRepository 为例:

<?php
use AlibabaCloud\Client\AlibabaCloud;
use AlibabaCloud\Client\Exception\ClientException;
use AlibabaCloud\Client\Exception\ServerException;

// Download:https://github.com/aliyun/openapi-sdk-php
// Usage:https://github.com/aliyun/openapi-sdk-php/blob/master/README.md

AlibabaCloud::accessKeyClient('<accessKeyId>', '<accessSecret>')
                        ->regionId('cn-hangzhou')
                        ->asDefaultClient();

try {
    $result = AlibabaCloud::roa()
                          ->product('codeup')
                          ->scheme('https') // https | http
                          ->version('2020-04-14')
                          ->pathPattern('/api/v3/projects')
                          ->method('POST')
                          ->options([
                                        'query' => [
                                          'OrganizationId' => '<OrganizationId>',
                                        ],
                                    ])
                          ->body('{
    "name": "<RepoName>",
    "path": "<RepoPath>",
    "visibility_level": 10,
    "namespace_id": 123
}')
                          ->request();
    print_r($result->toArray());
} catch (ClientException $e) {
    echo $e->getErrorMessage() . PHP_EOL;
} catch (ServerException $e) {
    echo $e->getErrorMessage() . PHP_EOL;
}