uniapp中使用百度ocr识别引入项目

uniapp中使用百度ocr识别引入项目

官网申请地址

orcAPI文档地址

1.先获取token

javascript 复制代码
	const getToken = () => {
		uni.request({
			url: 'https://aip.baidubce.com/oauth/2.0/token',
			method: 'POST',
			data: {
				grant_type: 'client_credentials',
				client_id: '**', apikey
				client_secret: '**', skey
			},
			header: {
				'Content-Type': 'application/x-www-form-urlencoded',
			},
			success: res => {
				uni.setStorageSync('access_token', res.data.access_token); // 获取到token存起来 后面调用 api要用
			},
		});
	};

2.根据需求调用api

javascript 复制代码
	const identification = () => {
		// 测试身份证识别
		uni.request({
			url: 'https://aip.baidubce.com/rest/2.0/ocr/v1/idcard?access_token=' + uni.getStorageSync('access_token'), 
			method: 'POST',
			data: {
				url: '****',
				id_card_side: 'front',
			},
			header: {
				'Content-Type': 'application/x-www-form-urlencoded',
			},
			success: res => {
				console.log(res); //读取结束 json
			},
		});
	};
相关推荐
码兄科技4 天前
24小时自助健身房系统软件开发实战指南:功能设计与部署方案
java·spring boot·uni-app
2501_916007474 天前
苹果商店iOS应用上架费用全面解析:开发者计划与审核费用计算
android·ios·小程序·https·uni-app·iphone·webview
2501_916008894 天前
如何实现iOS App代码混淆:SwiftShield使用指南
android·ios·小程序·https·uni-app·iphone·webview
楚识科技4 天前
电力电网 OCR 落地实践:轻量级模型 CPU 推理与鲲鹏 + 昇腾信创适配
ocr
2501_916008894 天前
怎么用 Godot 导出 iOS 应用并上架 App Store?签名字段该填什么?
android·ios·小程序·https·uni-app·iphone·webview
郑州光合科技余经理4 天前
同城外卖小程序开发:下单成功后,后台导出能不能对上用户端状态
开发语言·前端·git·后端·uni-app·php·ai编程
白远山5 天前
城市电竞陪玩调度系统实战:从派单算法到多端协同的架构拆解
java·架构·uni-app·需求分析
巡山小钻风来也5 天前
【保姆级教程】自定义数据集微调PP-OCRv6文本检测模型
python·ocr·paddlepaddle
白远山6 天前
上海24小时自助健身房系统软件开发实战指南
java·架构·uni-app·需求分析
山顶夕景6 天前
【文档解析】2026年技术发展和趋势
ocr·文档解析·agentic