评论请求
parent
6b450ee18f
commit
8035e308be
@ -0,0 +1,107 @@
|
||||
package com.baiye.requert;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baiye.core.constant.TiktokRequestConstants;
|
||||
import com.baiye.core.util.StringUtils;
|
||||
import com.baiye.properties.TiktokProperties;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author jt
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class RequestTiktok {
|
||||
private final TiktokProperties tiktokProperties;
|
||||
|
||||
/**
|
||||
* 搜索视频
|
||||
*/
|
||||
public JSONObject searchVideo(String vendorId, String keyWord) {
|
||||
JSONObject jsonObject = twoJson();
|
||||
jsonObject.putOpt("vendorId", vendorId);
|
||||
jsonObject.putOpt("keyWord", keyWord);
|
||||
String s = firstJson(jsonObject);
|
||||
String post = HttpUtil.post(tiktokProperties.getGatewayHost().concat(TiktokRequestConstants.TIK_TOK_SEARCH_VIDEO), s);
|
||||
if (StringUtils.isNotBlank(post)) {
|
||||
JSONObject json = JSONUtil.parseObj(post);
|
||||
if (json.getInt("status_code") == 0) {
|
||||
return JSONUtil.parseObj(post);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取视频的评论
|
||||
*
|
||||
* @param vendorId
|
||||
* @param awemeId
|
||||
* @return
|
||||
*/
|
||||
public JSONObject getVideoCommentList(String vendorId, String awemeId) {
|
||||
JSONObject jsonObject = twoJson();
|
||||
jsonObject.putOpt("vendorId", vendorId);
|
||||
jsonObject.putOpt("awemeId", awemeId);
|
||||
String s = firstJson(jsonObject);
|
||||
String post = HttpUtil.post(tiktokProperties.getGatewayHost().concat(TiktokRequestConstants.TIK_TOK_COMMENT_VIDEO_LIST), s);
|
||||
if (StringUtils.isNotBlank(post)) {
|
||||
JSONObject json = JSONUtil.parseObj(post);
|
||||
if (json.getInt("status_code") == 0) {
|
||||
return JSONUtil.parseObj(post);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 评论视频的评论
|
||||
*
|
||||
* @param vendorId
|
||||
* @param awemeId
|
||||
* @return
|
||||
*/
|
||||
public JSONObject optCommentVideoComment(String vendorId, String awemeId, String commentId, String content) {
|
||||
JSONObject jsonObject = twoJson();
|
||||
jsonObject.putOpt("vendorId", vendorId);
|
||||
jsonObject.putOpt("awemeId", awemeId);
|
||||
jsonObject.putOpt("commentId", commentId);
|
||||
jsonObject.putOpt("content", content);
|
||||
String s = firstJson(jsonObject);
|
||||
String post = HttpUtil.post(tiktokProperties.getGatewayHost().concat(TiktokRequestConstants.TIK_TOK_OPT_COMMENT_VIDEO_LIST), s);
|
||||
if (StringUtils.isNotBlank(post)) {
|
||||
JSONObject json = JSONUtil.parseObj(post);
|
||||
if (json.getInt("status_code") == 0) {
|
||||
return JSONUtil.parseObj(post);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param jsonObject
|
||||
* @return
|
||||
*/
|
||||
|
||||
private String firstJson(JSONObject jsonObject) {
|
||||
JSONObject json = new JSONObject();
|
||||
json.putOpt("sessionKey", tiktokProperties.getSessionKey());
|
||||
json.putOpt("data", jsonObject);
|
||||
return JSONUtil.toJsonStr(json);
|
||||
}
|
||||
|
||||
private JSONObject twoJson() {
|
||||
JSONObject childrenJson = new JSONObject();
|
||||
|
||||
childrenJson.putOpt("offset", 0);
|
||||
childrenJson.putOpt("checkLogin", false);
|
||||
childrenJson.putOpt("checkProxyInfo", false);
|
||||
return childrenJson;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue