PHP实现小程序OCR实名认证
此demo仅用于身份证识别,OCR内所有基本都通用,修改一下请求的接口及类型即可
基于laravel框架
public function demo(Request $request){
###文件上传至本地及获取绝对路径
$file = $request->file('file');
$newFile = date('Y-m-d');
$url_path = 'uploads/'.$newFile;
if ($file->isValid()) {
$clientName = $file->getClientOriginalName();
$entension = $file->getClientOriginalExtension();
$newName = md5(date("Y-m-d H:i:s") . $clientName) . "." . $entension;
$file->move($url_path, $newName);
$namePath = $url_path . '/' . $newName; #文件绝对路径
}
###进入正题
$file = $namePath; #获取本地文件路径
$type = 'photo';
#配置
$APPID = APPID;#小程序id
$APPSECRET = APPSEC;#小程序密钥
#获取a