🆕 #4028 【公众号】实现 OCR 菜单识别的接口
This commit is contained in:
@@ -138,4 +138,23 @@ public class WxMaOcrServiceImpl implements WxOcrService {
|
||||
FILE_COMM, imgFile);
|
||||
return WxOcrCommResult.fromJson(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxOcrMenuResult menu(String imgUrl) throws WxErrorException {
|
||||
try {
|
||||
imgUrl = URLEncoder.encode(imgUrl, StandardCharsets.UTF_8.name());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// ignore cannot happen
|
||||
}
|
||||
|
||||
final String result = this.service.post(String.format(MENU, imgUrl), (String) null);
|
||||
return WxOcrMenuResult.fromJson(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxOcrMenuResult menu(File imgFile) throws WxErrorException {
|
||||
String result = this.service.execute(OcrDiscernRequestExecutor.create(this.service.getRequestHttp()),
|
||||
FILE_MENU, imgFile);
|
||||
return WxOcrMenuResult.fromJson(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -403,6 +403,8 @@ public class WxMaApiUrlConstants {
|
||||
String FILE_BIZ_LICENSE = "https://api.weixin.qq.com/cv/ocr/bizlicense";
|
||||
String COMM = "https://api.weixin.qq.com/cv/ocr/comm?img_url=%s";
|
||||
String FILE_COMM = "https://api.weixin.qq.com/cv/ocr/comm";
|
||||
String MENU = "https://api.weixin.qq.com/cv/ocr/menu?img_url=%s";
|
||||
String FILE_MENU = "https://api.weixin.qq.com/cv/ocr/menu";
|
||||
}
|
||||
|
||||
public interface Product {
|
||||
|
||||
Reference in New Issue
Block a user