评论请求

master
wujingtao 2 years ago
parent 6b450ee18f
commit 8035e308be

@ -43,31 +43,27 @@ public interface TiktokRequestConstants {
/**
*
*
*/
String TIK_TOK_OPT_COMMENT_VIDEO_LIST = "/api/video/optCommentVideoComment";
/**
*
*
*/
String TIK_TOK_DELETE_COMMENT = "/api/video/delComment";
/**
*
*/
String SEARCH_VIDEO = "/api/search/searchVideo";
String TIK_TOK_SEARCH_VIDEO = "/api/search/searchVideo";
/**
*
*/
String AWEME_DETAIL = "/api/video/awemeDetail";
String TIK_TOK_AWEME_DETAIL = "/api/video/awemeDetail";
}

@ -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…
Cancel
Save