composer require jayxtt999/huaweicloud-sdk-php:dev-master
####华为云相关sdk 主要是云服务器部分以及云服务器附加的业务属性 目前相关的有
- Ecs
- Evs
- Iam
- Ims
- Vps
后续会新增
<?php
require_once __DIR__ . 'autoload.php';
use HwCloud\Common\Signer;
use HwCloud\DataInterFace\DataVolume;
use HwCloud\DataInterFace\Eip;
use HwCloud\DataInterFace\SingleDataVolume;
use HwCloud\DataInterFace\SystemVolume;
use HwCloud\EcsClient;
$hwKey = 'xxxxx';
$hwSecret = 'xxxxx';
$cred = new Signer($hwKey,$hwSecret);
$region = 'cn-south-1';
$client = new EcsClient($cred, $region);
//获取服务器详情
$result = $client->describe($projectId, $instanceId);
if (!$result || !isset($result['server'])) {
echo ('huawei request:' . json_encode(['url' => $client->curlUrl, 'params' => $client->curlData]));
echo '获取实例信息失败' . $ecsApi->client->getError();exit;
}
<?php
require_once __DIR__ . 'autoload.php';
require_once __DIR__ . 'EcsApi.php';
//封装为EcsApi
$ecsApi = new EcsApi();
$regionId = 'cn-south-1';
//获取服务器详情
$ecsApi = new EcsApi($regionId);
$result = $ecsApi->describe($projectId, $instanceId);
if (!$result || !isset($result['server'])) {
echo ('huawei request:' . json_encode(['url' => $client->curlUrl, 'params' => $client->curlData]));
echo '获取实例信息失败' . $ecsApi->client->getError();exit;
}
var_dump($result);