Forráskód Böngészése

广告违规素材推送

zhaoxian 1 éve
szülő
commit
4910ef6fc7

+ 14 - 55
jeecg-boot-module-system/src/main/java/cn/com/ctop/toutiao/modules/material/controller/ByteDanceVideoInfoController.java

@@ -16,15 +16,19 @@ import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.DeleteMapping;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.PutMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.Part;
 import java.io.IOException;
 import java.util.Arrays;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.Map;
 
 /**
  * @Description: 今日头条视频素材信息
@@ -180,69 +184,24 @@ public class ByteDanceVideoInfoController {
     public CallbackResponse illegalVideosPush(HttpServletRequest request,
                                               @RequestParam(value = "challenge", defaultValue = "0") int challenge,
                                               @RequestParam(value = "event", defaultValue = "") String event) throws IOException {
+        log.info("广告违规素材推送--------------------------challenge= " + challenge + ";event= " + event);
         // 处理 verify 事件
-//        if (null != event && event.equals("verify_webhook")) {
-//            return new CallbackResponse(BaseResponse.ok(), challenge);
-//        }
-        log.info("=========================");
-        log.info("challenge= " + challenge);
-        log.info("event= " + event);
-        Enumeration pNames = request.getParameterNames();
-        while (pNames.hasMoreElements()) {
-            String name = (String) pNames.nextElement();
-            log.info("---循环参数:" + name + " = " + request.getParameter(name));
+        if (null != event && event.equals("verify_webhook")) {
+            return new CallbackResponse(BaseResponse.ok(), challenge);
         }
 
         // 订阅任务配置页面的 "验证密钥"
         String secretKey = "1e87cef23427480997cc60ea9f538ac9";
         // 数据接收,验证消息
         AuthTokenUtil.InputStreamCacher cacher = new AuthTokenUtil.InputStreamCacher(request.getInputStream());
-        log.info("cacher= " + cacher);
         boolean isValidToken = AuthTokenUtil.isValidToken(secretKey, cacher, request.getHeader("X-Open-Signature"));
         log.info("isValidToken=" + isValidToken);
         if (!isValidToken) {
             return new CallbackResponse(new BaseResponse(400, "invalid token"), 0);
         }
+        JSONObject result = JSONObject.parseObject(new String(AuthTokenUtil.readAsBytes(cacher)));
+        System.out.println("返回结果:" + result.toJSONString());
         // 数据处理流程...
         return new CallbackResponse(BaseResponse.ok(), 0);
     }
-
-    /**
-     * 广告违规素材推送
-     */
-    @RequestMapping(value = "/illegalVideosPush2", method = {RequestMethod.GET, RequestMethod.POST})
-    public CallbackResponse illegalVideosPush2(HttpServletRequest request,
-                                               @RequestParam(value = "challenge", defaultValue = "0") int challenge,
-                                               @RequestParam(value = "event", defaultValue = "") String event) throws IOException {
-        System.out.println("=========================");
-        System.out.println("challenge= " + challenge);
-        System.out.println("event= " + event);
-        Enumeration pNames = request.getParameterNames();
-        while (pNames.hasMoreElements()) {
-            String name = (String) pNames.nextElement();
-            System.out.println(name + " = " + request.getParameter(name));
-        }
-/*
-        // 订阅任务配置页面的 "验证密钥"
-        String secretKey = "1e87cef23427480997cc60ea9f538ac9";
-        // 数据接收,验证消息
-        AuthTokenUtil.InputStreamCacher cacher = new AuthTokenUtil.InputStreamCacher(request.getInputStream());
-        System.out.println("cacher= "+cacher);
-        boolean isValidToken = AuthTokenUtil.isValidToken(secretKey, cacher, request.getHeader("X-Open-Signature"));
-        System.out.println("isValidToken=" + isValidToken);
-        if (!isValidToken) {
-            return new CallbackResponse(new BaseResponse(400, "invalid token"), 0);
-        }
-
-        Map<String, String[]> parameterMap2 = request.getParameterMap();
-        System.out.println("------------------" + parameterMap2);
-        for (Map.Entry<String, String[]> stringEntry : parameterMap2.entrySet()) {
-            System.out.println("--------------key:" + stringEntry.getKey() + "   value:" + stringEntry.getValue());
-        }*/
-
-
-        // 数据处理流程...
-        return new CallbackResponse(BaseResponse.ok(), challenge);
-    }
-
 }

+ 4 - 5
jeecg-boot-module-system/src/main/java/cn/com/ctop/toutiao/modules/tool/callback/AuthTokenUtil.java

@@ -38,11 +38,10 @@ public class AuthTokenUtil {
             return false;
         }
         String reSignature = genSignature(secretKey,readAsBytes(cacher));
-        logger.info("secretKey: " + secretKey);
-        logger.info("content: " + new String(readAsBytes(cacher)));
-        logger.info("content2: " + readAsBytes(cacher));
-        logger.info("signature: " + signature);
-        logger.info("reSignature: " + reSignature);
+//        logger.info("secretKey: " + secretKey);
+//        logger.info("content: " + new String(readAsBytes(cacher)));
+//        logger.info("signature: " + signature);
+//        logger.info("reSignature: " + reSignature);
         return signature.equals(reSignature);
     }