byteplus_sdk / byteplus-php-sdk-v2
Package info
github.com/byteplus-sdk/byteplus-php-sdk-v2
pkg:composer/byteplus_sdk/byteplus-php-sdk-v2
v1.0.3
2026-08-03 09:32 UTC
Requires
- php: >=5.5
- ext-curl: *
- ext-json: *
- ext-mbstring: *
- guzzlehttp/guzzle: ^6.2 || ^7.0
README
中文 | English
Byteplus SDK for PHP
Requirements
PHP 5.5 and later
Installation & Usage
Composer
To install the bindings via Composer, add the following to composer.json:
{
"require": {
"byteplus_sdk/byteplus-php-sdk-v2": "v1.0.0"
}
}
Then run composer install
Getting Started
Please follow the installation procedure
SDK 详细使用文档(凭证配置、Endpoint、Transport、超时、重试、异常处理、Debug)请参考:SDK 接入文档
Endpoint 设置
如果您要自定义SDK的Endpoint,可以按照以下示例代码设置:
$config = \Byteplus\Common\Configuration::getDefaultConfiguration() ->setAk("Your AK") ->setSk("Your SK") ->setRegion("cn-beijing") ->setHost("ecs.cn-beijing-autodriving.byteplusapi.com");
Byteplus标准的Endpoint规则说明:
| Regional 服务 | Global 服务 |
|---|---|
{service}.{region}.byteplusapi.com 例如:云服务ecs在cn-beijing-autodriving Region域名为: ecs.cn-beijing-autodriving.byteplusapi.com |
{service}.byteplusapi.com 例如:访问控制iam为Global服务,域名为: iam.byteplusapi.com |
注:
- Service中存在_符号时,Endpoint时需转为-符号。存在大写字母时需转成小写。
SDK 示例
<?php require_once(__DIR__ . '/vendor/autoload.php'); $config = \Byteplus\Common\Configuration::getDefaultConfiguration() ->setAk("Your AK") ->setSk("Your SK") ->setRegion("cn-beijing"); $apiInstance = new \Byteplus\Vpc\Api\VPCApi( // 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 ); $body = new \Byteplus\Vpc\Model\CreateVpcRequest(); $body->setClientToken("token-123456789") ->setCidrBlock("192.168.0.0/16") ->setDnsServers(array("10.0.0.1", "10.1.1.2")); try { $result = $apiInstance->createVpc($body); print_r($result); } catch (Exception $e) { echo 'Exception when calling VPCApi->createVpc: ', $e->getMessage(), PHP_EOL; } ?>
Security and privacy
This project takes security seriously. For vulnerability reporting and supported versions, see SECURITY.md