|
@@ -316,13 +316,71 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
|
|
params.put("photoId", photoId);
|
|
params.put("photoId", photoId);
|
|
params.put("commentId", commentId);
|
|
params.put("commentId", commentId);
|
|
System.out.println(new Gson().toJson(params));
|
|
System.out.println(new Gson().toJson(params));
|
|
|
|
+ Map<String, String> headers = getHeaders();
|
|
|
|
+ headers.put("Content-Type", "application/x-www-form-urlencoded");
|
|
|
|
+ headers.put("kpn", "GAME_ZONE");
|
|
|
|
+ headers.put("kpf", "PC_WEB");
|
|
HttpClientEntity httpClientEntity = new HttpClientEntity();
|
|
HttpClientEntity httpClientEntity = new HttpClientEntity();
|
|
HttpClientUtils httpClientUtils = new HttpClientUtils();
|
|
HttpClientUtils httpClientUtils = new HttpClientUtils();
|
|
httpClientEntity.setCloseableHttpClient(httpClientUtils.createSSLClientDefault());
|
|
httpClientEntity.setCloseableHttpClient(httpClientUtils.createSSLClientDefault());
|
|
- httpClientEntity.setUrl("https://id.kuaishou.com/pass/kuaishou/login/qr/callback");
|
|
|
|
|
|
+ httpClientEntity.setUrl("https://live.kuaishou.com/rest/wd/comment/delete");
|
|
httpClientEntity.setResult("");
|
|
httpClientEntity.setResult("");
|
|
httpClientEntity.setCookieStore(cookieTransfer(kuaishouUserCookie.getCookie()));
|
|
httpClientEntity.setCookieStore(cookieTransfer(kuaishouUserCookie.getCookie()));
|
|
- httpClientEntity.setHeaders(getHeaders());
|
|
|
|
|
|
+ List<Cookie> list = httpClientEntity.getCookieStore().getCookies();
|
|
|
|
+ String did = "";
|
|
|
|
+ for (Cookie ck : list) {
|
|
|
|
+ if (ck.getName().equals("did")) {
|
|
|
|
+ did = ck.getValue();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ headers.put("Referer", "https://live.kuaishou.com/u/" + kuaishouUserCookie.getEid() + "/" + photoId + "?did=" + did);
|
|
|
|
+ httpClientEntity.setHeaders(headers);
|
|
|
|
+ httpClientEntity.setParams(params);
|
|
|
|
+ httpClientEntity = httpClientUtils.httpPostParamRequest(httpClientEntity);
|
|
|
|
+ try {
|
|
|
|
+ ObjectMapper mapper = new ObjectMapper();
|
|
|
|
+ resultMap = mapper.readValue(httpClientEntity.getResult(), new TypeReference<Map<String, Object>>() {
|
|
|
|
+ });
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return resultMap;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public Map<String, Object> commentAdd(String ksid, String photoId, String principalId, String content, Long replyToCommentId, Long replyTo) {
|
|
|
|
+ LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
|
+ QueryWrapper<KuaishouUserCookie> queryWrapper = new QueryWrapper<KuaishouUserCookie>();
|
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
|
+ queryWrapper.eq("user_id", user.getId());
|
|
|
|
+ queryWrapper.eq("ksid", ksid);
|
|
|
|
+ KuaishouUserCookie kuaishouUserCookie = kuaishouUserCookieService.getOne(queryWrapper);
|
|
|
|
+ if (kuaishouUserCookie != null) {
|
|
|
|
+ Map<String, Object> params = new HashMap<String, Object>();
|
|
|
|
+ params.put("photoId", photoId);
|
|
|
|
+ params.put("principalId", principalId);
|
|
|
|
+ params.put("content", content);
|
|
|
|
+ params.put("replyToCommentId", replyToCommentId);
|
|
|
|
+ params.put("replyTo", replyTo);
|
|
|
|
+ Map<String, String> headers = getHeaders();
|
|
|
|
+ headers.put("Content-Type", "application/x-www-form-urlencoded");
|
|
|
|
+ headers.put("kpn", "GAME_ZONE");
|
|
|
|
+ headers.put("kpf", "PC_WEB");
|
|
|
|
+ System.out.println(new Gson().toJson(params));
|
|
|
|
+ HttpClientEntity httpClientEntity = new HttpClientEntity();
|
|
|
|
+ HttpClientUtils httpClientUtils = new HttpClientUtils();
|
|
|
|
+ httpClientEntity.setCloseableHttpClient(httpClientUtils.createSSLClientDefault());
|
|
|
|
+ httpClientEntity.setUrl("https://live.kuaishou.com/rest/wd/photo/comment/add");
|
|
|
|
+ httpClientEntity.setResult("");
|
|
|
|
+ List<Cookie> list = httpClientEntity.getCookieStore().getCookies();
|
|
|
|
+ String did = "";
|
|
|
|
+ for (Cookie ck : list) {
|
|
|
|
+ if (ck.getName().equals("did")) {
|
|
|
|
+ did = ck.getValue();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ headers.put("Referer", "https://live.kuaishou.com/u/" + kuaishouUserCookie.getEid() + "/" + photoId + "?did=" + did);
|
|
|
|
+ httpClientEntity.setHeaders(headers);
|
|
httpClientEntity.setParams(params);
|
|
httpClientEntity.setParams(params);
|
|
httpClientEntity = httpClientUtils.httpPostParamRequest(httpClientEntity);
|
|
httpClientEntity = httpClientUtils.httpPostParamRequest(httpClientEntity);
|
|
try {
|
|
try {
|
|
@@ -341,7 +399,7 @@ public class KuaishouWebInterfaceServiceImpl implements IKuaishouWebInterfaceSer
|
|
try {
|
|
try {
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
JsonNode jsonNode = mapper.readTree(json);
|
|
JsonNode jsonNode = mapper.readTree(json);
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("MMM d, yyyy H:m:s aaa");
|
|
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("MMM d, yyyy h:m:s aa", Locale.ENGLISH);
|
|
if (jsonNode != null) {
|
|
if (jsonNode != null) {
|
|
JsonNode cookiesNode = jsonNode.get("cookies");
|
|
JsonNode cookiesNode = jsonNode.get("cookies");
|
|
if (cookiesNode != null && cookiesNode.isArray()) {
|
|
if (cookiesNode != null && cookiesNode.isArray()) {
|