安装 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;
}
文档内容是否对您有帮助?