抖音评论获取与回复源码项目

这个项目分享的如何基于抖音平台,开发的java源码:

API覆盖率超过95%, 只需要简单的修改一下配置文件, 就能轻松调用api.
自动集成官方SDK, 切换使用原生一样方便! 多种选择, 轻松适配!
根据视频大小, 自动切换视频分片上传, 轻松避免异常, 保证接口安全.
接口分类清晰, 操作简单明了

相关的支持的文档和功能:支持评论,回复评论列表。

 

评论列表
Scope: item.comment 需要申请权限 需要用户授权 该接口用于获取评论列表。

注意:

抖音的 OAuth API 以https://open.douyin.com/开头。
注意参数中 item_id 作为 url 参数时,必须 encode,只对 item_id 单独进行 encode


评论回复列表
Scope: item.comment 需要申请权限 需要用户授权 该接口用于获取评论回复列表。

注意:

抖音的 OAuth API 以https://open.douyin.com/开头。
注意参数中 item_id 作为 url 参数时,必须 encode,只对 item_id 单独进行 encode
注意参数中 comment_id 作为 url 参数时,必须 encode,只对 comment_id 单独进行 encode

回复视频评论
Scope: item.comment 需要申请权限 需要用户授权 该接口用于回复视频评论。只能回复授权用户自己发布的视频。

根据文档实现的源码:

import com.douyin.open.api.ItemCommentApi;
import com.douyin.open.models.ItemCommentItemCommentBody;
import com.douyin.open.models.ItemCommentItemCommentInlineResponse200;
import com.douyin.open.models.ItemCommentItemCommentInlineResponse2001;
import org.springframework.web.client.RestClientException;

/**
 * @Description 普通用户互动管理API
 * @Date 2020/9/15 15:23
 * @Author by 尘心
 */
public class NormalUserInteractManager {

    private ItemCommentApi itemCommentApi;

    public NormalUserInteractManager() {
        itemCommentApi = new ItemCommentApi();
    }

    /**
     * 评论列表
     * * Scope: item.comment
     * @param openId 通过/oauth/access_token/获取,用户唯一标志
     * @param accessToken 调用/oauth/access_token/生成的token,此token需要用户授权。
     * @param pageSize 每页数量
     * @param itemId 视频id
     * @param pageNum 第几页
     */
    public ItemCommentItemCommentInlineResponse200 getCommentList(String openId, String accessToken,String itemId, Integer pageNum,Integer pageSize) {
        long pageRow = 0;
        if (pageNum!=null&&pageNum>0) {
            pageRow = (long)(pageNum*pageSize - pageSize);
        }

        ItemCommentItemCommentInlineResponse200 result = null;
        try {
            result = itemCommentApi.itemCommentListGet(openId, accessToken, pageSize, itemId, pageRow);
        } catch (RestClientException e) {
            e.printStackTrace();
        }
        return result;
    }

     /**
     * 评论回复列表
     * * Scope: `item.comment`
     * <p><b>200</b>
     * @param openId 通过/oauth/access_token/获取,用户唯一标志
     * @param accessToken 调用/oauth/access_token/生成的token,此token需要用户授权。
     * @param pageSize 每页数量
     * @param itemId 视频id
     * @param commentId 评论id
     * @param pageNum 分页游标, 第一页请求cursor是0, response中会返回下一页请求用到的cursor, 同时response还会返回has_more来表明是否有更多的数据。
     */
    public ItemCommentItemCommentInlineResponse200 getItemCommentReplyList(String openId, String accessToken,String itemId,String commentId, Integer pageNum,Integer pageSize) {
        long pageRow = 0;
        if (pageNum!=null&&pageNum>0) {
            pageRow = (long)(pageNum*pageSize - pageSize);
        }

        ItemCommentItemCommentInlineResponse200 result = null;
        try {
            result = itemCommentApi.itemCommentReplyListGet(openId, accessToken, pageSize, itemId, commentId, pageRow);
        } catch (RestClientException e) {
            e.printStackTrace();
        }
        return result;
    }

    /**
     *
     * 回复视频评论
     * * Scope: item.comment
     * <p><b>200</b>
     * @param openId 通过/oauth/access_token/获取,用户唯一标志
     * @param accessToken 调用/oauth/access_token/生成的token,此token需要用户授权。
     * @param body The body parameter
     */
    public ItemCommentItemCommentInlineResponse2001 getCommentReplyPost(String openId, String accessToken ,ItemCommentItemCommentBody body) {
        ItemCommentItemCommentInlineResponse2001 result = null;
        try {
            result = itemCommentApi.itemCommentReplyPost(openId, accessToken, body);
        } catch (RestClientException e) {
            e.printStackTrace();
        }

        return result;
    }
}
© 2022 GitHub, Inc.
Term

 完整源码地址:

https://github.com/LovebuildJ/douyin-open-api-sdk

  • 2
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Softboy_TM

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值