com.netease.yidun.sdk.antispam.crawler.v3.CrawlerJobActiveCallbackDemo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of yidun-java-sdk-demo Show documentation
Show all versions of yidun-java-sdk-demo Show documentation
Yidun OpenAPI SDK Demo for Java
The newest version!
package com.netease.yidun.sdk.antispam.crawler.v3;
import com.netease.yidun.sdk.antispam.callback.ActiveCallbackResp;
import com.netease.yidun.sdk.antispam.crawler.v3.callback.request.CrawlerJobActiveCallbackV3Request;
import com.netease.yidun.sdk.core.utils.SignatureUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
/**
* @author xietieli
* @version 2023-12-05
*/
@RestController
@RequestMapping("callback/receive")
public class CrawlerJobActiveCallbackDemo {
private static final String SECRET_KEY = "SECRET_KEY";
@RequestMapping("/crawlerJob")
public ActiveCallbackResp receiveCallback(HttpServletRequest request, CrawlerJobActiveCallbackV3Request callbackResp) {
try {
if (!SignatureUtils.verifySignature(request.getParameterMap(), SECRET_KEY)) {
return ActiveCallbackResp.fail(ActiveCallbackResp.SIGN_ERROR);
}
CrawlerJobActiveCallbackV3Request activeCallbackResult = callbackResp.parseCrawlerJobCallbackData();
// 根据需要解析字段,具体返回字段的说明,请参考官方接口文档中字段说明 https://support.dun.163.com/documents/606191408732381184?docId=611046942165569536
System.out.println(activeCallbackResult);
return ActiveCallbackResp.ok();
} catch (Exception e) {
e.printStackTrace();
return ActiveCallbackResp.fail(ActiveCallbackResp.SERVER_ERROR);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy