|
@@ -2,6 +2,10 @@ package cn.com.ctop.toutiao.modules.material.controller;
|
|
|
|
|
|
|
|
import cn.com.ctop.toutiao.modules.material.entity.ByteDanceVideoInfo;
|
|
import cn.com.ctop.toutiao.modules.material.entity.ByteDanceVideoInfo;
|
|
|
import cn.com.ctop.toutiao.modules.material.service.IByteDanceVideoInfoService;
|
|
import cn.com.ctop.toutiao.modules.material.service.IByteDanceVideoInfoService;
|
|
|
|
|
+import cn.com.ctop.toutiao.modules.tool.callback.AuthTokenUtil;
|
|
|
|
|
+import cn.com.ctop.toutiao.modules.tool.callback.BaseResponse;
|
|
|
|
|
+import cn.com.ctop.toutiao.modules.tool.callback.CallbackResponse;
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -15,7 +19,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
+import javax.servlet.http.Part;
|
|
|
|
|
+import java.io.IOException;
|
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
|
|
|
+import java.util.Collection;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @Description: 今日头条视频素材信息
|
|
* @Description: 今日头条视频素材信息
|
|
@@ -162,4 +170,39 @@ public class ByteDanceVideoInfoController {
|
|
|
}
|
|
}
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ *广告违规素材推送
|
|
|
|
|
+ */
|
|
|
|
|
+ @RequestMapping(value = "/illegalVideosPush", method = { RequestMethod.GET, RequestMethod.POST })
|
|
|
|
|
+ public CallbackResponse illegalVideosPush(HttpServletRequest request,
|
|
|
|
|
+ @RequestBody String data,
|
|
|
|
|
+ @RequestParam(value = "challenge", defaultValue = "0") int challenge,
|
|
|
|
|
+ @RequestParam(value = "event", defaultValue = "") String event) throws IOException {
|
|
|
|
|
+ // 处理 verify 事件
|
|
|
|
|
+ if (null != event && event.equals("verify_webhook")) {
|
|
|
|
|
+ return new CallbackResponse(BaseResponse.ok(), challenge);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 订阅任务配置页面的 "验证密钥"
|
|
|
|
|
+ String secretKey = System.getenv("bd881f3bcd894ed48638dfb63eb627cf");
|
|
|
|
|
+
|
|
|
|
|
+ // 数据接收,验证消息
|
|
|
|
|
+ AuthTokenUtil.InputStreamCacher cacher = new AuthTokenUtil.InputStreamCacher(request.getInputStream());
|
|
|
|
|
+ boolean isValidToken = AuthTokenUtil.isValidToken(secretKey, cacher, request.getHeader("X-Open-Signature"));
|
|
|
|
|
+ if (!isValidToken) {
|
|
|
|
|
+ return new CallbackResponse(new BaseResponse(400, "invalid token"), 0);
|
|
|
|
|
+ }
|
|
|
|
|
+ Map<String, String[]> parameterMap = request.getParameterMap();
|
|
|
|
|
+ System.out.println(parameterMap);
|
|
|
|
|
+
|
|
|
|
|
+ System.out.println(data);
|
|
|
|
|
+// JSONObject parse = JSONObject.parseObject(data);
|
|
|
|
|
+// System.out.println(parse);
|
|
|
|
|
+
|
|
|
|
|
+ // 数据处理流程...
|
|
|
|
|
+ return new CallbackResponse(BaseResponse.ok(), 0);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|