← Endpoint 配置 | Transport(English) | 代理配置 →
默认
scheme-https
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$config = \Volcengine\Common\Configuration::getDefaultConfiguration()
->setAk("Your ak")
->setSk("Your sk")
->setSchema('https'); # 非必填,默认为https,可以定义为http默认
verifySsl-true
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$config = \Volcengine\Common\Configuration::getDefaultConfiguration()
->setAk("Your ak")
->setSk("Your sk")
->setVerifySsl(false); #非必填,默认为true需要验证ssl,false为不需要验证<?php
$config = \Volcengine\Common\Configuration::getDefaultConfiguration()
->setSslCaCert('/etc/ssl/certs/ca-bundle.crt')
->setCertFile('/path/to/client.crt')
->setKeyFile('/path/to/client.key')
->setAssertHostname(true);默认
= TLS 1.2
目前只支持自定义HTTPClient的方式实现;如果没有特殊要求,建议不要修改。
<?php
require_once(__DIR__ . '/vendor/autoload.php');
$config = \Volcengine\Common\Configuration::getDefaultConfiguration()
->setAk("Your ak")
->setSk("Your sk")
->setRegion('cn-beijing');
$apiInstance = new \Volcengine\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([
'curl' => [
CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1_2, // 指定 TLS 1.2
],
]),
$config
);
$body = new \Volcengine\Vpc\Model\CreateVpcRequest();
$body->setCidrBlock("192.168.0.0/16");
try {
$result = $apiInstance->createVpc($body);
print_r($result);
} catch (Exception $e) {
echo 'Exception when calling VPCApi->createVpc: ', $e->getMessage(), PHP_EOL;
}← Endpoint 配置 | Transport(English) | 代理配置 →