|
|
@@ -2,14 +2,14 @@ package cn.binarywang.wx.miniapp.api.impl; |
|
|
|
|
|
|
|
import cn.binarywang.wx.miniapp.api.WxMaSecCheckService; |
|
|
|
import cn.binarywang.wx.miniapp.api.WxMaService; |
|
|
|
import cn.binarywang.wx.miniapp.bean.WxMaMediaAsyncCheckResult; |
|
|
|
import com.google.gson.JsonObject; |
|
|
|
import java.io.File; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; |
|
|
|
import me.chanjar.weixin.common.error.WxErrorException; |
|
|
|
import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; |
|
|
|
|
|
|
|
import java.io.File; |
|
|
|
|
|
|
|
/** |
|
|
|
* <pre> |
|
|
|
* |
|
|
@@ -20,6 +20,7 @@ import java.io.File; |
|
|
|
*/ |
|
|
|
@AllArgsConstructor |
|
|
|
public class WxMaSecCheckServiceImpl implements WxMaSecCheckService { |
|
|
|
|
|
|
|
private WxMaService service; |
|
|
|
|
|
|
|
@Override |
|
|
@@ -31,16 +32,24 @@ public class WxMaSecCheckServiceImpl implements WxMaSecCheckService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public boolean checkMessage(String msgString) { |
|
|
|
public boolean checkMessage(String msgString) throws WxErrorException { |
|
|
|
JsonObject jsonObject = new JsonObject(); |
|
|
|
jsonObject.addProperty("content", msgString); |
|
|
|
try { |
|
|
|
this.service.post(MSG_SEC_CHECK_URL, jsonObject.toString()); |
|
|
|
} catch (WxErrorException e) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
this.service.post(MSG_SEC_CHECK_URL, jsonObject.toString()); |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public WxMaMediaAsyncCheckResult mediaCheckAsync(String mediaUrl, int mediaType) |
|
|
|
throws WxErrorException { |
|
|
|
JsonObject jsonObject = new JsonObject(); |
|
|
|
jsonObject.addProperty("media_url", mediaUrl); |
|
|
|
jsonObject.addProperty("media_type", mediaType); |
|
|
|
|
|
|
|
return WxMaMediaAsyncCheckResult |
|
|
|
.fromJson(this.service.post(MEDIA_CHECK_ASYNC_URL, jsonObject.toString())); |
|
|
|
} |
|
|
|
|
|
|
|
} |