You need to enable JavaScript to run this app.
导航

获取内容详情

最近更新时间2023.11.21 14:41:58

首次发布时间2021.10.18 11:12:18

本接口主要针对需要实现收藏场景的客户。您可以通过调用该接口获取内容状态和内容详情,避免C端用户访问到已下架的内容。
您需要自行实现在列表页或者详情页收藏文章/视频内容,在用户收藏内容时,将用户及内容id的对应关系存下,在用户进入收藏列表页时,调用本接口以获取内容标题、封面图、作者信息等,并实现自定义UI。

获取单条内容

通过GroupId获取单条文章/视频内容

请求方式

请求方法

GET/POST(Content-Type: application/x-www-form-urlencoded)

请求url

https://mercury.volcengineapi.com/?Action=SingleArticleV2&Version=2021-01-01

请求header

ServiceName:content

请求参数

参数描述类型是否必填说明
ApiVersion接口版本int固定传4
Partner渠道号String
AccessToken用户唯一标识String
GroupId内容idString获取个性化内容”接口返回该字段
CustomVideoDefinition指定视频分辨率String枚举值:360p、480p、540p、720p、1080p、all(全部)。
横版短视频支持:360p(默认)、480p、540p、720p、1080p
竖版小视频支持:540p(默认)
默认不传时,短视频下发360p,小视频下发540p,传all时下发视频所有的分辨率。
如果请求的分辨率对于该视频不存在,则会自动降级一档返回内容作为兜底。
特别注意: 分辨率的升档会增加cdn的播放成本,需客户侧谨慎评估,详细咨询火山引擎侧。

响应参数

参数
描述
类型
说明
Result
内容详情
Result
内容的详细信息

请求示例

public static void main(String[] args) {
        //初始化一个service
        StreamConsumerService streamConsumerService = StreamConsumerServiceImpl.getInstance();

        //设置ak,sk 此为请求的凭证
        streamConsumerService.setAccessKey("ak");
        streamConsumerService.setSecretKey("sk");
        //初始化一个request

        SingleArticleRequest req = new SingleArticleRequest();
        req.setTimestamp(LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")));
        req.setAccessToken("accessToken");
        req.setPartner("partner");
        req.setGroupId("7138365312264569377");

        try {
            SingleArticleResponseV2 response = streamConsumerService.singleArticleV2(req);
            System.out.println(JSON.toJSONString(response));
        } catch (Exception e) {
            e.printStackTrace();
        }
    } 

响应示例

{
    "ResponseMetadata": {
        "Action": "SingleArticleV2",
        "Region": "cn-beijing",
        "RequestId": "20231116121644A83AF1F1F68DA528F1A5",
        "Service": "content",
        "Version": "2021-01-01"
    },
    "Result": {
        "Abstract": "为什么越有钱越不快乐?女老师讲得头头是道,笑得我肚儿疼",
        "ArticleType": "短视频",
        "ArticleUrl": "https://open.toutiao.com/a7273752338563760675/?***",
        "CommentCount": 568,
        "CommentUrl": "https://open.toutiao.com/a7273752338563760675/comment/?***",
        "CoverImages": [
            {
                "Height": 1098,
                "Url": "https://p6-open-sign.onewsimg.com/***",
                "Width": 2000
            }
        ],
        "CoverMode": 1,
        "DiggCount": 12117,
        "DiggStatus": false,
        "GroupId": "7273752338563760675",
        "HasVideo": true,
        "PublishTime": 1693552438,
        "ShareCount": 5520,
        "ShareUrl": "https://open.toutiao.com/a7273752338563760675/?***",
        "Title": "为什么越有钱越不快乐?女老师讲得头头是道,笑得我肚儿疼",
        "UserInfo": {
            "AvatarUrl": "https://p3-open-sign.onewsimg.com/***",
            "Description": "好看的皮囊千篇一律,有趣的灵魂万里挑一",
            "Follow": false,
            "FollowerCount": 3128823,
            "HomePage": "https://open.toutiao.com/u61521344424/?***",
            "Name": "七兜酱妹子",
            "UserId": 61521344424,
            "UserVerified": true,
            "VerifiedContent": "优质搞笑领域创作者"
        },
        "VideoDetail": {
            "VideoDuration": 663.467,
            "VideoList": [
                {
                    "Definition": "360p",
                    "Height": 360,
                    "Url": "http://partner.365yg.com/video/url/?***",
                    "Width": 640
                }
            ]
        },
        "VideoWatchCount": 438281
    }
}
获取多条内容

传入多个GroupId,批量的获取内容

请求方式

请求方法

GET/POST(Content-Type: application/x-www-form-urlencoded)

请求url

https://mercury.volcengineapi.com/?Action=MultiArticleV2&Version=2021-01-01

请求header

ServiceName:content

请求参数

参数描述类型是否必填说明
ApiVersion接口版本int固定传4
Partner渠道号String
AccessToken用户唯一标识String
GroupIDs内容id列表String最多支持20个GroupID,多个GroupID以英文逗号进行分隔
CustomVideoDefinition指定视频分辨率String枚举值:360p、480p、540p、720p、1080p、all(全部)。
横版短视频支持:360p(默认)、480p、540p、720p、1080p
竖版小视频支持:540p(默认)
默认不传时,短视频下发360p,小视频下发540p,传all时下发视频所有的分辨率。
如果请求的分辨率对于该视频不存在,则会自动降级一档返回内容作为兜底。
特别注意: 分辨率的升档会增加cdn的播放成本,需客户侧谨慎评估,详细咨询火山引擎侧。

响应参数

参数
描述
类型
说明
Result
内容详情
Map< String,Article>
内容详情,Map< GroupId,Article>

请求示例

public static void main(String[] args) {
        //初始化一个service
        StreamConsumerService streamConsumerService = StreamConsumerServiceImpl.getInstance();

        //设置ak,sk 此为请求的凭证
        streamConsumerService.setAccessKey("ak");
        streamConsumerService.setSecretKey("sk");
        //初始化一个request
        MultiArticlesRequest req = new MultiArticlesRequest();
        req.setTimestamp(LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")));
        req.setAccessToken("accesstoken");
        req.setPartner("partner");
        List<String> groupIdList = new ArrayList<>();
        groupIdList.add("7278981857889731072,6758714736730178060");
        req.setGroupIds(groupIdList);

        try {
            MultiArticlesResponseV2 response = streamConsumerService.multiArticlesV2(req);
            System.out.println(JSON.toJSONString(response));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

响应示例

{
    "ResponseMetadata": {
        "Action": "MultiArticleV2",
        "Region": "cn-beijing",
        "RequestId": "20231116121555002EE2AD85D21627D353",
        "Service": "content",
        "Version": "2021-01-01"
    },
    "Result": {
        "7290558092113216000": {
            "Abstract": "这一路上他意志坚定,***",
            "ArticleReadCount": 2034,
            "ArticleType": "图文",
            "ArticleUrl": "https://open.toutiao.com/a7290558092113216000/?***",
            "CommentCount": 23,
            "CommentUrl": "https://open.toutiao.com/a7290558092113216000/comment/?***",
            "CoverMode": 0,
            "DiggCount": 234,
            "DiggStatus": false,
            "GroupId": "7290558092113216000",
            "HasVideo": false,
            "PublishTime": 1697677800,
            "ShareCount": 4,
            "ShareUrl": "https://open.toutiao.com/a7290558092113216000/?***",
            "Title": "800里莫贺延碛,让玄奘险些放弃西天取经,这里如今还有什么遗迹",
            "UserInfo": {
                "AvatarUrl": "https://p3-open-sign.onewsimg.com/***",
                "Description": "爱好摄影、深爱旅行。努力记录下普通人旅途的点点滴滴。",
                "Follow": false,
                "FollowerCount": 691364,
                "HomePage": "https://open.toutiao.com/u75640832821/?***",
                "Name": "***",
                "UserId": 75640832821,
                "UserVerified": true,
                "VerifiedContent": "优质旅游领域创作者"
            }
        },
        "7293100913563009574": {
            "Abstract": "",
            "ArticleType": "小视频",
            "ArticleUrl": "https://feedcoop.douyin.com/d7293100913563009574/?***",
            "CommentCount": 12,
            "CommentUrl": "https://feedcoop.douyin.com/d7293100913563009574/comment/?***",
            "CoverImages": [
                {
                    "Height": 1920,
                    "Url": "https://p3-open-sign.onewsimg.com/***",
                    "Width": 1080
                }
            ],
            "CoverMode": 1,
            "DiggCount": 4349,
            "DiggStatus": false,
            "GroupId": "7293100913563009574",
            "HasVideo": true,
            "PublishTime": 1698057348,
            "ShareCount": 2177,
            "ShareUrl": "https://open.toutiao.com/d7293100913563009574/?***",
            "Title": "***",
            "UserInfo": {
                "AvatarUrl": "https://p6-open-sign.onewsimg.com/***",
                "Description": "***",
                "Follow": false,
                "FollowerCount": 2897782,
                "HomePage": "https://feedcoop.douyin.com/u1622512794348414/?***",
                "Name": "娱乐最前沿",
                "UserId": 1622512794348414,
                "UserVerified": true,
                "VerifiedContent": "娱乐视频自媒体"
            },
            "VideoDetail": {
                "VideoDuration": 39.289,
                "VideoList": [
                    {
                        "Definition": "540p",
                        "Height": 960,
                        "Url": "http://partner.365yg.com/video/url/?***",
                        "Width": 540
                    }
                ]
            },
            "VideoWatchCount": 1448519
        }
    }
}