<?php
require_once 'curl.func.php';
$appkey = 'your_appkey_here';//你的appkey
$url = "https://api.jisuepc.com/drivinglicenserecognition/recognize?appkey=$appkey";
$post = array(
'pic'=>base64_encode(file_get_contents('sfz1.jpg')), //'@'.realpath('11.jpg')
);
$result = curlOpen($url, array('post'=>$post, 'isupfile'=>true));
$jsonarr = json_decode($result, true);
if($jsonarr['status'] != 0)
{
echo $jsonarr['msg'];
exit();
}
$data = $jsonarr['result'];
print_r($data);
// 1. 前置依赖:确保已安装 axios(执行 npm install axios)
const fs = require('fs');
const path = require('path');
const axios = require('axios');
// 2. 读取图片文件并转换为 Base64(不带前缀)
let base64Data;
try {
// 修改为你的图片路径
const imagePath = path.join(__dirname, 'drivinglicense.png');
const imageBuffer = fs.readFileSync(imagePath);
base64Data = imageBuffer.toString('base64'); // 正确赋值
} catch (err) {
console.error('图片处理失败:', err.message);
process.exit(1); // 直接退出进程(避免后续使用未定义的变量)
}
// 3. 配置请求参数
const appkey = 'your_appkey_here'; // 替换为你的真实 appkey
const apiUrl = `https://api.jisuepc.com/drivinglicenserecognition/recognize?appkey=${appkey}`;
// 4. 直接发送 POST 请求
axios.post(apiUrl, `pic=${encodeURIComponent(base64Data)}`, {
headers: {
'Content-Type': 'application/x-www-form-urlencoded' // 必须指定表单类型
}
})
.then(response => {
// 处理成功响应
console.log('----------------------------------');
console.log('HTTP 状态码:', response.status);
// 业务逻辑判断(根据 API 文档调整)
if (response.data.status === 0) {
console.log('识别成功:');
console.log('车牌前缀:', response.data.result.lsprefix);
console.log('车牌号:', response.data.result.lsnum);
console.log('车牌类型:', response.data.result.lstype);
console.log('车牌类型名称:', response.data.result.lstypename);
console.log('所有人:', response.data.result.realname);
console.log('地址:', response.data.result.address);
console.log('品牌型号:', response.data.result.cartype);
console.log('车架号:', response.data.result.frameno);
console.log('发动机号:', response.data.result.engineno);
console.log('注册日期:', response.data.result.regdate);
console.log('发证日期:', response.data.result.issuedate);
console.log('使用性质:', response.data.result.usetype);
} else {
console.log('识别失败:', response.data.msg);
}
})
.catch(error => {
// 统一错误处理
console.error('请求失败!');
});
import requests
import base64
appkey = 'your_appkey_here'
url = f"https://api.jisuepc.com/drivinglicenserecognition/recognize?appkey={appkey}"
with open('sfz1.jpg', 'rb') as file:
pic_base64 = base64.b64encode(file.read()).decode('utf-8')
data = {'pic': pic_base64
}
response = requests.post(url, data=data)
jsonarr = response.json()
if jsonarr['status'] != 0:
print(jsonarr['msg'])
else:
result = jsonarr['result']
print(f"{result['lsprefix']} {result['lsnum']} {result['lstype']} {result['lstypename']}")
print(f"{result['realname']} {result['address']} {result['cartype']} {result['frameno']}")
print(f"{result['engineno']} {result['regdate']} {result['issuedate']} {result['usetype']}")