Polyv Help Center

Help Center

advertisingService

Updated: 2023-09-22 17:47:34

1. Create Video Advertisement

Description

通过上传广告文件及时间范围等参数创建视频广告
接口地址(仅做说明使用):https://api.polyv.net/v2/advertising/%s/create

Call Constraints

  1. API calls are rate-limited. Click for details. For common call exceptions, click here.

Unit Test

    @Test
    public void testCreateAdvertising() throws IOException, NoSuchAlgorithmException {
        VodCreateAdvertisingRequest vodCreateAdvertisingRequest = new VodCreateAdvertisingRequest();
        String vodCreateAdvertisingResponse = null;
        try {
            String filePath = getClass().getResource("/img/cover.jpg").getPath();
            vodCreateAdvertisingRequest.setStartDate(super.getDate(2021, 2, 22))
                    .setEndDate(super.getDate(2021, 3, 22))
                    .setTitle("测试广告")
                    .setFile(new File(filePath))
                    .setSize(2)
                    .setCategoryIds("1")
                    .setLocation(1)
                    .setStatus(10)
                    .setUpTime("00:00:00")
                    .setOffTime("23:59:59")
                    .setNote("测试广告描述")
                    .setSkipAd("Y")
                    .setSkipOffset(1)
                    .setSkipButtonLabel("跳过广告");
            vodCreateAdvertisingResponse = new VodAdvertisingServiceImpl().createAdvertising(
                    vodCreateAdvertisingRequest);
            Assert.assertNotNull(vodCreateAdvertisingResponse);
            if (vodCreateAdvertisingResponse != null) {
                log.debug("测试创建视频广告成功,{}", vodCreateAdvertisingResponse);
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }

Unit Test Description

  1. On a correct request, a String object is returned. The B-end processes business logic based on this object.

  2. If request parameter validation fails, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [ Input parameter [xxx.chat.VodxxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty] ]

  3. If the server encounters an exception, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [ Error returned from Polyv request, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]

Request Parameter Description

Parameter Name Required Type Description
startDate true Date Advertisement start date, format: yyyy-MM-dd
endDate true Date Advertisement end date, format: yyyy-MM-dd
title true String Advertisement title
file true File Advertisement material. Pre-roll and post-roll ads support: JPEG, GIF, PNG, FLV, MP4; Pause ads support: SWF, PNG, JPEG, GIF; Pop-up ads support: PNG, JPEG, GIF.
size true Integer Advertisement duration, mandatory for all except pause ads. Unit: seconds
categoryIds false String Category ID(s). For multiple categories, separate with commas. Default value is default category 1 [Corresponds to the cataids field in the API documentation]
location false Integer Advertisement type: Pre-roll 1, Pause 2, Post-roll 3, Pop-up 4; Default is 1: Pre-roll
popLocation false Integer Pop-up advertisement position, mandatory when type is pop-up. Bottom-right 1, Top-right 2, Bottom-left 3, Top-left 4
popUpTime false Integer Time for the pop-up to appear, in seconds. Mandatory when type is pop-up
status false Integer Advertisement status: Online 10, Pending 1, Offline 0; Default is 10: Online
upTime false String Advertisement start time, format: HH:mm:ss, default is 00:00:00
offTime false String Advertisement end time, format: HH:mm:ss, default is 23:59:59
note false String Advertisement description
skipAd false String Y to enable skip ad, N to disable. Only valid for pre-roll ads. Default is N: Disable skip ad
skipOffset false Integer Seconds after which skipping is allowed. Mandatory when skipAd is Y
skipButtonLabel false String Skip button label, default is "Skip"

Return Object Description

Returns the video advertisement ID upon successful creation.




2. Query Video Advertisement List

Description

分页查询视频广告列表
接口地址(仅做说明使用):https://api.polyv.net/v2/advertising/%s/list

Call Constraints

  1. API calls are rate-limited. Click for details. For common call exceptions, click here.

Unit Test

    @Test
    public void testGetAdvertisingList() throws IOException, NoSuchAlgorithmException {
        VodGetAdvertisingListRequest vodGetAdvertisingListRequest = new VodGetAdvertisingListRequest();
        VodGetAdvertisingListResponse vodGetAdvertisingListResponse = null;
        try {
            vodGetAdvertisingListRequest.setCurrentPage(1).setPageSize(10);
            vodGetAdvertisingListResponse = new VodAdvertisingServiceImpl().getAdvertisingList(
                    vodGetAdvertisingListRequest);
            Assert.assertNotNull(vodGetAdvertisingListResponse);
            if (vodGetAdvertisingListResponse != null) {
                log.debug("测试查询视频广告列表成功,{}", JSON.toJSONString(vodGetAdvertisingListResponse));
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }

Unit Test Description

  1. On a correct request, a VodGetAdvertisingListResponse object is returned. The B-end processes business logic based on this object.

  2. If request parameter validation fails, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [ Input parameter [xxx.chat.VodxxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty] ]

  3. If the server encounters an exception, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [ Error returned from Polyv request, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]

Request Parameter Description

Parameter Name Required Type Description
currentPage false Integer Page number, default is 1 [Corresponds to the page field in the API documentation]
pageSize false Integer Number of records per page, default is 20

Return Object Description

Parameter Name Type Description
contents Array Result set [See AdvertisingInfo Parameter Description for details]
pageSize Integer Number of records per page, default is 20
currentPage Integer Current page number [Corresponds to the pageNumber field in the API documentation]
totalItems Integer Total number of records
totalPage Integer Total number of pages [Corresponds to the totalPages field in the API documentation]
AdvertisingInfo Parameter Description
Parameter Name Type Description
advertisingId String Advertisement ID [Corresponds to the adid field in the API documentation]
title String Advertisement title
note String Advertisement description
userId String User ID [Corresponds to the userid field in the API documentation]
location Integer Advertisement type (Pre-roll 1, Pause 2, Post-roll 3, Pop-up 4)
matterUrl String Advertisement material URL [Corresponds to the matterurl field in the API documentation]
size Integer Advertisement duration (s)
playNum Integer Number of plays [Corresponds to the playnum field in the API documentation]
addrUrl String Link URL [Corresponds to the addrurl field in the API documentation]
stasis Integer Whether the ad is floating (Yes 1, No 2), default is 2: No [Corresponds to the isstatis field in the API documentation]
upTime Date Delivery start time, format HH:mm:ss [Corresponds to the uptime field in the API documentation]
offTime Date Delivery end time, format HH:mm:ss [Corresponds to the offtime field in the API documentation]
startDate Date Delivery start date, format: yyyy-MM-dd [Corresponds to the startdate field in the API documentation]
endDate Date Delivery end date, format: yyyy-MM-dd [Corresponds to the enddate field in the API documentation]
lastModified Date Modification time [Corresponds to the ptime field in the API documentation]
status Integer Delivery status (Online 10, Pending 1, Offline 0), default is 10: Online
popUptime Integer Time for the pop-up to appear, in seconds [Corresponds to the popuptime field in the API documentation]
categoryIds String Content category ID(s). For multiple categories, separate with commas. Default value is default category 1 [Corresponds to the cataids field in the API documentation]
popLocation Integer Pop-up position (Bottom-right 1, Top-right 2, Bottom-left 3, Top-left 4) [Corresponds to the poplocation field in the API documentation]






3. Update Video Advertisement

Description

通过广告id修改视频广告信息
接口地址(仅做说明使用):https://api.polyv.net/v2/advertising/%s/edit

Call Constraints

  1. API calls are rate-limited. Click for details. For common call exceptions, click here.

Unit Test

    @Test
    public void testUpdateAdvertising() throws IOException, NoSuchAlgorithmException {
        VodUpdateAdvertisingRequest vodUpdateAdvertisingRequest = new VodUpdateAdvertisingRequest();
        Boolean vodUpdateAdvertisingResponse = null;
        try {
            String filePath = getClass().getResource("/img/cover.jpg").getPath();
            vodUpdateAdvertisingRequest.setAdvertisingId("ea7a04430dd04d01853d")
                    .setCategoryIds("1")
                    .setStartDate(super.getDate(2021, 2, 22))
                    .setEndDate(super.getDate(2021, 3, 22))
                    .setTitle("测试广告(Junit测试,勿删)")
                    .setFile(new File(filePath))
                    .setSize(2)
                    .setCategoryIds("1")
                    .setLocation(1)
                    .setStatus(0)
                    .setUpTime("00:00:00")
                    .setOffTime("23:59:59")
                    .setNote("测试广告描述")
                    .setSkipAd("Y")
                    .setSkipOffset(1)
                    .setSkipButtonLabel("跳过广告");
            vodUpdateAdvertisingResponse = new VodAdvertisingServiceImpl().updateAdvertising(
                    vodUpdateAdvertisingRequest);
            Assert.assertTrue(vodUpdateAdvertisingResponse);
            if (vodUpdateAdvertisingResponse) {
                log.debug("测试修改视频广告成功");
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }

Unit Test Description

  1. On a correct request, a Boolean object is returned. The B-end processes business logic based on this object.

  2. If request parameter validation fails, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [ Input parameter [xxx.chat.VodxxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty] ]

  3. If the server encounters an exception, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [ Error returned from Polyv request, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]

Request Parameter Description

Parameter Name Required Type Description
advertisingId true String Advertisement information ID [Corresponds to the adid field in the API documentation]
startDate false Date Advertisement start date, format: yyyy-MM-dd
endDate false Date Advertisement end date, format: yyyy-MM-dd
title false String Advertisement title
file false File Advertisement material. Pre-roll and post-roll ads support: JPEG, GIF, PNG, FLV, MP4; Pause ads support: SWF, PNG, JPEG, GIF; Pop-up ads support: PNG, JPEG, GIF.
size false Integer Advertisement duration, mandatory for all except pause ads. Unit: seconds
categoryIds false String Category ID(s). For multiple categories, separate with commas. Default value is default category 1 [Corresponds to the cataids field in the API documentation]
location false Integer Advertisement type: Pre-roll 1, Pause 2, Post-roll 3, Pop-up 4; Default is 1: Pre-roll
popLocation false Integer Pop-up advertisement position, mandatory when type is pop-up. Bottom-right 1, Top-right 2, Bottom-left 3, Top-left 4
popUpTime false Integer Time for the pop-up to appear, in seconds. Mandatory when type is pop-up
status false Integer Advertisement status: Online 10, Pending 1, Offline 0; Default is 10: Online
upTime false String Advertisement start time, format: HH:mm:ss, default is 00:00:00
offTime false String Advertisement end time, format: HH:mm:ss, default is 23:59:59
note false String Advertisement description
skipAd false String Y to enable skip ad, N to disable. Only valid for pre-roll ads. Default is N: Disable skip ad
skipOffset false Integer Seconds after which skipping is allowed. Mandatory when skipAd is Y
skipButtonLabel false String Skip button label, default is "Skip"

Return Object Description

true indicates successful update, false indicates failure.




4. Delete Video Advertisement

Description

通过广告id删除视频广告
接口地址(仅做说明使用):https://api.polyv.net/v2/advertising/%s/delete

Call Constraints

  1. API calls are rate-limited. Click for details. For common call exceptions, click here.

Unit Test

    @Test
    public void testDeleteAdvertising() throws IOException, NoSuchAlgorithmException {
        VodDeleteAdvertisingRequest vodDeleteAdvertisingRequest = new VodDeleteAdvertisingRequest();
        Boolean vodDeleteAdvertisingResponse = null;
        try {
            //准备测试数据
            String advertisingId = super.createAdvertisingOther();
            vodDeleteAdvertisingRequest.setAdvertisingId(advertisingId);
            vodDeleteAdvertisingResponse = new VodAdvertisingServiceImpl().deleteAdvertising(
                    vodDeleteAdvertisingRequest);
            Assert.assertTrue(vodDeleteAdvertisingResponse);
            if (vodDeleteAdvertisingResponse) {
                log.debug("测试删除视频广告成功");
            }
        } catch (PloyvSdkException e) {
            //参数校验不合格 或者 请求服务器端500错误,错误信息见PloyvSdkException.getMessage()
            log.error(e.getMessage(), e);
            // 异常返回做B端异常的业务逻辑,记录log 或者 上报到ETL 或者回滚事务
            throw e;
        } catch (Exception e) {
            log.error("SDK调用异常", e);
            throw e;
        }
    }

Unit Test Description

  1. On a correct request, a Boolean object is returned. The B-end processes business logic based on this object.

  2. If request parameter validation fails, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [ Input parameter [xxx.chat.VodxxxRequest] object validation failed, failed field [pic cannot be empty / msg cannot be empty] ]

  3. If the server encounters an exception, a PloyvSdkException is thrown. The error message is available via PloyvSdkException.getMessage(), e.g., [ Error returned from Polyv request, request serial number: 66e7ad29fd04425a84c2b2b562d2025b, error reason: invalid signature. ]

Request Parameter Description

Parameter Name Required Type Description
advertisingId true String Advertisement information ID [Corresponds to the adid field in the API documentation]

Return Object Description

true indicates successful deletion, false indicates failure.

联系客服,在线咨询