もくじ
今回のゴール
このAPIを叩くのがゴール
DescriptionBillBandwidthAndFluxList
https://intl.cloud.tencent.com/zh/document/api/267/36098
API Keyを発行しよう
認証情報を利用してAPIを叩く必要があります。
https://console.cloud.tencent.com/cam/capi
API Explorerを使おう
PHPでやってみる
$ mkdir tencent-cloud $ cd tencent-cloud tencent-cloud $ curl -sS https://getcomposer.org/installer | php
tencent-cloud $ vi composer.json
{
"require": {
"tencentcloud/tencentcloud-sdk-php": "^3.0"
}
}
tencent-cloud $ composer install
getDescribeBillBandwidthAndFluxList.php
<?php
require_once 'vendor/autoload.php';
use TencentCloud\Common\Credential;
use TencentCloud\Common\Profile\ClientProfile;
use TencentCloud\Common\Profile\HttpProfile;
use TencentCloud\Common\Exception\TencentCloudSDKException;
use TencentCloud\Live\V20180801\LiveClient;
use TencentCloud\Live\V20180801\Models\DescribeBillBandwidthAndFluxListRequest;
$secret_key_id = "AKIDxxxxx";
$secret_key = "yyyyy";
try {
$cred = new Credential($secret_key_id, $secret_key);
$httpProfile = new HttpProfile();
$httpProfile->setEndpoint("live.tencentcloudapi.com");
$clientProfile = new ClientProfile();
$clientProfile->setHttpProfile($httpProfile);
$client = new LiveClient($cred, "", $clientProfile);
$req = new DescribeBillBandwidthAndFluxListRequest();
$params = array(
"EndTime" => "2021-01-1400:10:00",
"StartTime" => "2021-01-1100:10:00"
);
$req->fromJsonString(json_encode($params));
$resp = $client->DescribeBillBandwidthAndFluxList($req);
print_r($resp->toJsonString());
}
catch(TencentCloudSDKException $e) {
echo $e;
}
実行
$ php getDescribeBillBandwidthAndFluxList.php
これでJSONが得られる





