$url = ‘https://aip.baidubce.com/oauth/2.0/token’;
$post_data[‘grant_type’] = ‘client_credentials’;
$post_data[‘client_id’] = ‘client_id’;
$post_data[‘client_secret’] = ‘client_secret’;
o = " " ; f o r e a c h ( o = ""; foreach ( o="";foreach(post_data as $k => $v) {
o . = " o .= " o.="k=" . urlencode($v) . “&”;
}
p o s t d a t a = s u b s t r ( post_data = substr( postdata=substr(o, 0, -1);
r e s = r e q u e s t p o s t ( res = request_post( res=requestpost(url, $post_data);
r e s = j s o n d e c o d e ( res = json_decode( res=jsondecode(res, true);
$token = $res[‘access_token’];
$path=“http://” . $_SERVER[‘HTTP_HOST’] . ‘/’ . $pinfo[‘pcvalue’];
$img = @file_get_contents(“http://” . $_SERVER[‘HTTP_HOST’] . ‘/’ . $pinfo[‘pcvalue’]);
//$img = @file_get_contents(‘sf1.jpg’);
i m g = b a s e 6 4 e n c o d e ( img = base64_encode( img=base64encode(img);
$bodys = array(
“image” => i m g , ) ; / / img, ); // img,);//pinfo[‘attributeid’] = 151;
switch ($pinfo[‘attributeid’]) {
case 172: //行驶证正面
$bodys[‘vehicle_license_side’] = ‘front’;
$url = ‘https://aip.baidubce.com/rest/2.0/ocr/v1/vehicle_license?access_token=’ . $token;
break;
case 171: //行驶证反面
$bodys[‘vehicle_license_side’] = ‘back’;
$url = ‘https://aip.baidubce.com/rest/2.0/ocr/v1/vehicle_license?access_token=’ . $token;
break;
case 205: //驾驶证
$url = ‘https://aip.baidubce.com/rest/2.0/ocr/v1/driving_license?access_token=’ . $token;
break;
case 151: //银行卡
$url = ‘https://aip.baidubce.com/rest/2.0/ocr/v1/bankcard?access_token=’ . $token;
break;
case 148: //身份证正面
$bodys[‘id_card_side’] = ‘front’;
$url = ‘https://aip.baidubce.com/rest/2.0/ocr/v1/idcard?access_token=’ . $token;
break;
case 149: //身份证反面
$bodys[‘id_card_side’] = ‘back’;
$url = ‘https://aip.baidubce.com/rest/2.0/ocr/v1/idcard?access_token=’ . $token;
break;
case 211: //壹佳客APP
$url=‘https://aip.baidubce.com/rest/2.0/ocr/v1/accurate_basic?access_token=’ . $token;
break;
}
r e s = r e q u e s t p o s t ( res = request_post( res=requestpost(url, $bodys);
$str = “
”;a r r = j s o n d e c o d e ( arr = json_decode( arr=jsondecode(res, true);
$arr[‘words_result’] = $pinfo[‘attributeid’] == 151 ? $arr[‘result’] : a r r [ ′ w o r d s r e s u l t ′ ] ; i f ( arr['words_result']; if ( arr[′wordsresult′];if(arr[‘words_result’]) {
$updatesql = “UPDATE " . e c s − > t a b l e ( ′ u s e r p r o d u c t i n f o ′ ) . " S E T r e m a r k = ′ ecs->table('user_product_info') . " SET remark=' ecs−>table(′userproductinfo′)."SETremark=′res’ WHERE id = ‘$infoid’”;
d b − > q u e r y ( db->query( db−>query(updatesql);
if ( KaTeX parse error: Expected '}', got 'EOF' at end of input: … foreach (arr[‘words_result’] as $k => $v) {
$str .= “”;
}
}
}
$str .= “
” . $k . “: | ” . KaTeX parse error: Expected 'EOF', got '}' at position 27: …/tr>"; }̲ } else { …arr[‘words_result’] as $k => $v) { $str .= “ |
” . $k . “: | ” . $v[‘words’] . “ |
$reArr = array(‘id’ => $infoid, ‘str’ => $str);
————————————————
版权声明:本文为CSDN博主「花花的牛」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq1714594061/article/details/105244893