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

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

前提条件

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

调用示例

设置回调事件

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

package com.volcengine.example.vod.callback;

import com.volcengine.service.vod.IVodService;
import com.volcengine.service.vod.impl.VodServiceImpl;
public class VodSetCallbackEventDemo {

    public static void main(String[] args) throws Exception {
        // Create a VOD instance in the specified region.
        // IVodService vodService = VodServiceImpl.getInstance("cn-north-1");
        IVodService vodService = VodServiceImpl.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/65641.
        // 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.
        // vodService.setAccessKey("your ak");
        // vodService.setSecretKey("your sk");

        try {
            com.volcengine.service.vod.model.request.VodSetCallbackEventRequest.Builder reqBuilder = com.volcengine.service.vod.model.request.VodSetCallbackEventRequest.newBuilder();
         reqBuilder.setSpaceName("your SpaceName");
         reqBuilder.setEvents("your Events");
         reqBuilder.setAuthEnabled("your AuthEnabled");
         reqBuilder.setPrivateKey("your PrivateKey");
         
            com.volcengine.service.vod.model.response.VodSetCallbackEventResponse resp = vodService.setCallbackEvent(reqBuilder.build());
            if (resp.getResponseMetadata().hasError()) {
                System.out.println(resp.getResponseMetadata().getError());
                System.exit(-1);
            }
            System.out.println(resp);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

添加回调订阅地址

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

package com.volcengine.example.vod.callback;

import com.volcengine.service.vod.IVodService;
import com.volcengine.service.vod.impl.VodServiceImpl;
public class VodAddCallbackSubscriptionDemo {

    public static void main(String[] args) throws Exception {
        // Create a VOD instance in the specified region.
        // IVodService vodService = VodServiceImpl.getInstance("cn-north-1");
        IVodService vodService = VodServiceImpl.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/65641.
        // 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.
        // vodService.setAccessKey("your ak");
        // vodService.setSecretKey("your sk");

        try {
            com.volcengine.service.vod.model.request.VodAddCallbackSubscriptionRequest.Builder reqBuilder = com.volcengine.service.vod.model.request.VodAddCallbackSubscriptionRequest.newBuilder();
         reqBuilder.setSpaceName("your SpaceName");
         reqBuilder.setUrl("your Url");
         reqBuilder.setContentType("your ContentType");
         
            com.volcengine.service.vod.model.response.VodAddCallbackSubscriptionResponse resp = vodService.addCallbackSubscription(reqBuilder.build());
            if (resp.getResponseMetadata().hasError()) {
                System.out.println(resp.getResponseMetadata().getError());
                System.exit(-1);
            }
            System.out.println(resp);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}