You need to enable JavaScript to run this app.
导航
其他配置
最近更新时间:2024.09.29 17:41:41首次发布时间:2022.08.03 11:07:54

本文为您提供了服务端 PHP SDK 的其他配置模块的接口调用示例。

前提条件

调用接口前,请先完成 SDK 的安装初始化

调用示例

设置回调事件

接口请求参数和返回参数详见 OpenAPI:设置回调事件

<?php
require('../../vendor/autoload.php');

use Volc\Service\Vod\Models\Request\VodSetCallbackEventRequest;
use Volc\Service\Vod\Models\Response\VodSetCallbackEventResponse;
use Volc\Service\Vod\Vod;

// Create a VOD instance in the specified region.
// $client = Vod::getInstance('cn-north-1');
$client = Vod::getInstance();

// Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/4408.
// The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
// During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
// $client->setAccessKey('your ak');
// $client->setSecretKey('your sk');

$request = new VodSetCallbackEventRequest();
$request->setSpaceName("your space name");
$request->setEvents("your event");
$request->setAuthEnabled("your auth enabled: 1 or 0");
$request->setPrivateKey("your private key");

$response = new VodSetCallbackEventResponse();
try {
    $response = $client->setCallbackEvent($request);
} catch (Exception $e) {
    echo $e, "\n";
} catch (Throwable $e) {
    echo $e, "\n";
}
if ($response->getResponseMetadata()->getError() != null) {
    print_r($response->getResponseMetadata()->getError());
}
echo $response->serializeToJsonString();
echo "\n";

添加回调订阅地址

接口请求参数和返回参数详见 OpenAPI:添加回调订阅地址

<?php
require('../../vendor/autoload.php');

use Volc\Service\Vod\Models\Request\VodAddCallbackSubscriptionRequest;
use Volc\Service\Vod\Models\Response\VodAddCallbackSubscriptionResponse;
use Volc\Service\Vod\Vod;

// Create a VOD instance in the specified region.
// $client = Vod::getInstance('cn-north-1');
$client = Vod::getInstance();

// Configure your Access Key ID (AK) and Secret Access Key (SK) in the environment variables or in the local ~/.volc/config file. For detailed instructions, see https://www.volcengine.com/docs/4/4408.
// The SDK will automatically fetch the AK and SK from the environment variables or the ~/.volc/config file as needed.
// During testing, you may use the following code snippet. However, do not store the AK and SK directly in your project code to prevent potential leakage and safeguard the security of all resources associated with your account.
// $client->setAccessKey('your ak');
// $client->setSecretKey('your sk');

$request = new VodAddCallbackSubscriptionRequest();
$request->setSpaceName("your space name");
$request->setUrl("your callback subscription url");
$request->setContentType("your ContentType");

$response = new VodAddCallbackSubscriptionResponse();
try {
    $response = $client->addCallbackSubscription($request);
} catch (Exception $e) {
    echo $e, "\n";
} catch (Throwable $e) {
    echo $e, "\n";
}
if ($response->getResponseMetadata()->getError() != null) {
    print_r($response->getResponseMetadata()->getError());
}
echo $response->serializeToJsonString();
echo "\n";