<?php
require_once 'curl.func.php';
$appkey = 'your_appkey_here';//你的appkey
$url = "https://api.jisuapi.com/businesslicenserecognition/recognize?appkey=$appkey";
$post = [
'pic'=>base64_encode(file_get_contents('sfz1.jpg'))
];
$result = curlOpen($url, ['post'=>$post, 'ssl'=>true]);
$jsonarr = json_decode($result, true);
if($jsonarr['status'] != 0)
{
echo $jsonarr['msg'];
exit();
}
$result = $jsonarr['result'];
echo $result['name'].' '.$result['creditno'].' '.$result['legalperson'].' '.$result['regcapital'].'
';
echo $result['regdate'].' '.$result['enddate'].' '.$result['regaddress'].' '.$result['scope'].'
';
echo $result['regorgan'];
import requests
import base64
appkey = 'your_appkey_here'
url = f"https://api.jisuapi.com/businesslicenserecognition/recognize?appkey={appkey}"
with open('sfz1.jpg', 'rb') as image_file:
encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
post_data = {
'pic': encoded_string
}
response = requests.post(url, data=post_data)
jsonarr = response.json()
if jsonarr['status'] != 0:
print(jsonarr['msg'])
exit()
result = jsonarr['result']
print(result['name'], result['creditno'], result['legalperson'], result['regcapital'])
print(result['regdate'], result['enddate'], result['regaddress'], result['scope'])
print(result['regorgan'])
// 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, 'business.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.jisuapi.com/businesslicenserecognition/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('识别内容:');
for (const [key, value] of Object.entries(response.data.result)) {
console.log(`${key.padEnd(8)}:`, value);
}
} else {
console.log('识别失败:', response.data.msg);
}
})
.catch(error => {
// 统一错误处理
console.error('请求失败!');
});