这个项目分享的如何基于抖音平台,开发的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