1
0
mirror of synced 2026-10-14 03:09:54 +08:00

🆕 #4028 【公众号】实现 OCR 菜单识别的接口

This commit is contained in:
Copilot
2026-07-14 14:29:19 +08:00
committed by GitHub
parent 83d7744425
commit 124ff523f3
7 changed files with 176 additions and 1 deletions

View File

@@ -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);
}
}

View File

@@ -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 {