条码识别
万维易源 官方文档
提供EAN_8、EAN_13、CODE_39、CODE_93、CODE_128、ITF、PDF_417、RSS_14、RSS_EXPANDED、UPC_A、UPC_E、UPC_EAN_EXTENSION、CODABAR等类型的条码(条形码)识别
基本说明:
接口地址:http://route.showapi.com/1129-4
返回格式:json
请求方式:get/post
请求示例:0
请求参数说明:
名称 类型 必填 说明
imgData String 必填 图片的base64编码
返回参数说明:
名称 类型 说明
ret_code String 错误码 0为成功 其他为失败
retText String 识别后的数据
JSON返回示例:
{
	"showapi_res_code": 0,
	"showapi_res_error": "",
	"showapi_res_body": {
		"ret_code": "0",
		"retText": "0123456789"
	}
}
服务级错误码参照
错误码 说明
-1 系统调用错误
-2 可调用次数或金额为0
-3 读取超时
-4 服务端返回数据解析错误
-5 后端服务器DNS解析错误
-6 服务不存在或未上线
-1000 系统维护
-1002 showapi_appid字段必传
-1003 showapi_sign字段必传
-1004 签名sign验证有误
-1005 showapi_timestamp无效
-1006 app无权限调用接口
-1007 没有订购套餐
-1008 服务商关闭对您的调用权限
-1009 调用频率受限
-1010 找不到您的应用
-1011 子授权app_child_id无效
-1012 子授权已过期或失效
-1013 子授权ip受限
完整教学代码示例
public static void main(String path[]) throws Exception {
URL u = new URL("http://route.showapi.com/1129-4?showapi_appid%3Dmyappid%26imgData%3D%2F9j%2F4AAQSkZJRgABAgAAAQABAAD%2F2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL%2F2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL%2FwAARCAAeAJYDASIAAhEBAxEB%2F8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL%2F8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0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2BlGlV9f18gaT%2FAMkh1P8A7e%2F%2FAEo0qvr%2BgAooooAKKKKACiiigArz%2FwCNv%2FJIdd%2F7d%2F8A0ojr0CvP%2Fjb%2FAMkh13%2Ft3%2F8ASiOgDz%2Fxb%2FyM%2FwAOv%2Bxr1P8A9OS0f%2FPVo8W%2F8jP8Ov8Asa9T%2FwDTktH%2FAM9WgDAsf%2BQH8FP%2Bwrcf%2Blsdc%2Fp3%2FMuf9ipqv%2FuQroLH%2FkB%2FBT%2FsK3H%2FAKWx1z%2Bnf8y5%2FwBipqv%2FALkKAOgs%2FwDkoes%2F9lAsP%2FRt3Xr%2Btf8AIsfFL%2Ftv%2FwCm2CvILP8A5KHrP%2FZQLD%2F0bd16%2FrX%2FACLHxS%2F7b%2F8AptgoA8%2F%2FAPnq1wGi%2FwDIz%2FC3%2Fth%2F6cp67%2F8A%2BerXAaL%2FAMjP8Lf%2B2H%2FpynoA9f1j%2Fknnwl%2F7Cuj%2FAPoo0eBP%2BSh%2BGv8Asn9r%2FwCjVo1j%2Fknnwl%2F7Cuj%2FAPoo0eBP%2BSh%2BGv8Asn9r%2FwCjVoA8g0n%2FAJJDqf8A29%2F%2BlGlV9f18gaT%2FAMkh1P8A7e%2F%2FAEo0qvr%2BgAooooAKKKKAP%2F%2FZ%26showapi_sign%3Dmysecret");
InputStream in = u.openStream();
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
byte buf[] = new byte[1024];
int read = 0;
while ((read = in .read(buf)) > 0) {
out.write(buf, 0, read);
}
} finally {
if ( in != null) {
in .close();
}
}
byte b[] = out.toByteArray();
System.out.println(new String(b, "utf-8"));
}
<?php
/**
 * Created by PhpStorm.
 * User: FZS
 * Time: 2019/3/15 17:50
 */
//----------------------------------
// 易源 条码识别 调用类
//----------------------------------
class freeApi{
    private $apiId = false; //易源appid
    private $apiSecret = false; //易源secret
    private $apiUrl = 'http://route.showapi.com/1129-4';
    public function __construct($apiid,$secretkey){
        $this->apiId = $apiid;
        $this->apiSecret = $secretkey;
    }
    /**
     * url拼接
     * @return string
     */
    private function handleParam($paramArr,$showapi_secret){
        $paraStr = "";
        $signStr = "";
        ksort($paramArr);
        foreach ($paramArr as $key => $val) {
            if ($key != '' && $val != '') {
                $signStr .= $key.$val;
                $paraStr .= $key.'='.urlencode($val).'&';
            }
        }
        $signStr .= $showapi_secret;//排好序的参数加上secret,进行md5
        $sign = strtolower(md5($signStr));
        $paraStr .= 'showapi_sign='.$sign;//将md5后的值作为参数,便于服务器的效验
        return '?'.$paraStr;
    }
    /**
     * 将JSON内容转为数据,并返回
     * @param string $content [内容]
     * @return array
     */
    public function returnArray($content){
        return json_decode($content,true);
    }
    /**
     * 获取 条码识别 结果
     * @return array
     */
    public function getResult(){
        $paramArr = [
            'showapi_appid'=> $this->apiId,
            'imgData'=> ""
        ];
        return $this->returnArray($this->freeApiCurl($this->apiUrl.$this->handleParam($paramArr,$this->apiSecret)));
    }
    /**
     * 请求接口返回内容
     * @param  string $url [请求的URL地址]
     * @param  string $params [请求的参数]
     * @param  int $ipost [是否采用POST形式]
     * @return  string
     */
    public function freeApiCurl($url,$params=false,$ispost=0){
        $ch = curl_init();
        curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 );
        curl_setopt( $ch, CURLOPT_HTTP_VERSION , CURL_HTTP_VERSION_1_1 );
        curl_setopt( $ch, CURLOPT_USERAGENT , 'free-api' );
        curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT , 60 );
        curl_setopt( $ch, CURLOPT_TIMEOUT , 60);
        curl_setopt( $ch, CURLOPT_RETURNTRANSFER , true );
        if( $ispost )
        {
            curl_setopt( $ch , CURLOPT_POST , true );
            curl_setopt( $ch , CURLOPT_POSTFIELDS , $params );
            curl_setopt( $ch , CURLOPT_URL , $url );
        }
        else
        {
            if($params){
                curl_setopt( $ch , CURLOPT_URL , $url.'?'.$params );
            }else{
                curl_setopt( $ch , CURLOPT_URL , $url);
            }
        }
        $response = curl_exec( $ch );
        if ($response === FALSE) {
            return false;
        }
        curl_close( $ch );
        return $response;
    }
}
//推荐使用npm安装使用sdk: npm install --save showapi-sdk
'use strict';

var showapiSdk = require('showapi-sdk');

//设置你测试用的appId和secret,img
var appId='';
var secret='';
//开启debug
//showapiSdk.debug(true);
if(!(appId&&secret)){
  console.error('请先设置appId等测试参数,详见样例代码内注释!')
  return;
}
//全局默认设置
showapiSdk.setting({
  url:"http://route.showapi.com/1129-4",//你要调用的API对应接入点的地址,注意需要先订购了相关套餐才能调
  appId:appId,//你的应用id
  secret:secret,//你的密钥
  timeout:5000,//http超时设置
  options:{//默认请求参数,极少用到
    testParam:'test'
  }
})

var request=showapiSdk.request();
request.appendText('imgData','/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAAeAJYDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldY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AEo0qvr+gAooooAKKKKAP//Z');
request.post(function(data){
  console.info(data)
})
package main

import (
"showSdk/normalRequest"
"fmt"
)
res := normalRequest.ShowapiRequest("http://route.showapi.com/1129-4",my_appId,"my_appSecret")
res.AddTextPara("imgData","/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAAeAJYDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIhMUEGE1FhByJxFDKBkaEII0KxwRVS0fAkM2JyggkKFhcYGRolJicoKSo0NTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqDhIWGh4iJipKTlJWWl5iZmqKjpKWmp6ipqrKztLW2t7i5usLDxMXGx8jJytLT1NXW19jZ2uHi4+Tl5ufo6erx8vP09fb3+Pn6/8QAHwEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoL/8QAtREAAgECBAQDBAcFBAQAAQJ3AAECAxEEBSExBhJBUQdhcRMiMoEIFEKRobHBCSMzUvAVYnLRChYkNOEl8RcYGRomJygpKjU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6goOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4uPk5ebn6Onq8vP09fb3+Pn6/9oADAMBAAIRAxEAPwD3+iiigArz/wCNv/JIdd/7d/8A0ojr0CvP/jb/AMkh13/t3/8ASiOgDz/xb/yM/wAOv+xr1P8A9OS0f/PVo8W/8jP8Ov8Asa9T/wDTktH/AM9WgDAsf+QH8FP+wrcf+lsdc/p3/Muf9ipqv/uQroLH/kB/BT/sK3H/AKWx1z+nf8y5/wBipqv/ALkKAOgs/wDkoes/9lAsP/Rt3Xr+tf8AIsfFL/tv/wCm2CvILP8A5KHrP/ZQLD/0bd16/rX/ACLHxS/7b/8AptgoA8//APnq1wGi/wDIz/C3/th/6cp67/8A+erXAaL/AMjP8Lf+2H/pynoA9f1j/knnwl/7Cuj/APoo0eBP+Sh+Gv8Asn9r/wCjVo1j/knnwl/7Cuj/APoo0eBP+Sh+Gv8Asn9r/wCjVoA8g0n/AJJDqf8A29/+lGlV9f18gaT/AMkh1P8A7e//AEo0qvr+gAooooAKKKKACiiigArz/wCNv/JIdd/7d/8A0ojr0CvP/jb/AMkh13/t3/8ASiOgDz/xb/yM/wAOv+xr1P8A9OS0f/PVo8W/8jP8Ov8Asa9T/wDTktH/AM9WgDAsf+QH8FP+wrcf+lsdc/p3/Muf9ipqv/uQroLH/kB/BT/sK3H/AKWx1z+nf8y5/wBipqv/ALkKAOgs/wDkoes/9lAsP/Rt3Xr+tf8AIsfFL/tv/wCm2CvILP8A5KHrP/ZQLD/0bd16/rX/ACLHxS/7b/8AptgoA8//APnq1wGi/wDIz/C3/th/6cp67/8A+erXAaL/AMjP8Lf+2H/pynoA9f1j/knnwl/7Cuj/APoo0eBP+Sh+Gv8Asn9r/wCjVo1j/knnwl/7Cuj/APoo0eBP+Sh+Gv8Asn9r/wCjVoA8g0n/AJJDqf8A29/+lGlV9f18gaT/AMkh1P8A7e//AEo0qvr+gAooooAKKKKAP//Z")
//res.AddFilePara("img", "C:\\Users\\showa\\Desktop\\使用过的\\4.png")//文件上传时设置
fmt.Println(res.Post())
# python3.6.5
# 需要引入requests包 :运行终端->进入python/Scripts ->输入:pip install requests
from ShowapiRequest import ShowapiRequest

r = ShowapiRequest("http://route.showapi.com/1129-4","my_appId","my_appSecret" )
r.addBodyPara("imgData", "/9j/4AAQSkZJRgABAgAAAQABAAD/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LHxS/7b/8AptgoA8//APnq1wGi/wDIz/C3/th/6cp67/8A+erXAaL/AMjP8Lf+2H/pynoA9f1j/knnwl/7Cuj/APoo0eBP+Sh+Gv8Asn9r/wCjVo1j/knnwl/7Cuj/APoo0eBP+Sh+Gv8Asn9r/wCjVoA8g0n/AJJDqf8A29/+lGlV9f18gaT/AMkh1P8A7e//AEo0qvr+gAooooAKKKKACiiigArz/wCNv/JIdd/7d/8A0ojr0CvP/jb/AMkh13/t3/8ASiOgDz/xb/yM/wAOv+xr1P8A9OS0f/PVo8W/8jP8Ov8Asa9T/wDTktH/AM9WgDAsf+QH8FP+wrcf+lsdc/p3/Muf9ipqv/uQroLH/kB/BT/sK3H/AKWx1z+nf8y5/wBipqv/ALkKAOgs/wDkoes/9lAsP/Rt3Xr+tf8AIsfFL/tv/wCm2CvILP8A5KHrP/ZQLD/0bd16/rX/ACLHxS/7b/8AptgoA8//APnq1wGi/wDIz/C3/th/6cp67/8A+erXAaL/AMjP8Lf+2H/pynoA9f1j/knnwl/7Cuj/APoo0eBP+Sh+Gv8Asn9r/wCjVo1j/knnwl/7Cuj/APoo0eBP+Sh+Gv8Asn9r/wCjVoA8g0n/AJJDqf8A29/+lGlV9f18gaT/AMkh1P8A7e//AEo0qvr+gAooooAKKKKAP//Z")
# r.addFilePara("img", r"C:\Users\showa\Desktop\使用过的\4.png") #文件上传时设置
res = r.post()
print(res.text) # 返回信息