互億無線 · 文檔中心

身份證OCR識別 - 代碼示例


Go對接身份證OCR識別DEMO示例
本文為您提供了Go語言版本的身份證OCR識別的DEMO示例,快速對接調(diào)用,輕松完成系統(tǒng)集成,智能識別身份證圖片中的文字內(nèi)容。

身份證OCR識別API接口文檔 點擊下載

身份證OCR識別接入指南 點擊訪問



// 接口類型:互億無線OCR識別接口
// 賬戶注冊:https://user.ihuyi.com/register.html
// 注意事項:
// DEMO僅作參考

package main

import (
	"crypto/md5"
	"encoding/hex"
	"fmt"
	"io/ioutil"
	"net/http"
	"net/url"
	"strconv"
	"strings"
	"time"
)

func GetMd5String(s string) string {
	h := md5.New()
	h.Write([]byte(s))
	return hex.EncodeToString(h.Sum(nil))
}
func main() {
	v := url.Values{}
	_now := strconv.FormatInt(time.Now().Unix(), 10)
	//fmt.Printf(_now)
	_account := "APIID"
	_password := "APIKEY"
	_app := "idcard"http://固定值
	_img_base64 := ""
	_img_url := "http://www.xx.com/xx.png"
	v.Set("account", _account)
	v.Set("password", GetMd5String(_account+_password+_app+_img_base64+_img_url+_now))
	v.Set("app", _app)
	v.Set("img_base64", _img_base64)
	v.Set("img_url", _img_url)
	v.Set("time", _now)
	//body := ioutil.NopCloser(strings.NewReader(v.Encode())) //把form數(shù)據(jù)編下碼
	body := strings.NewReader(v.Encode()) //把form數(shù)據(jù)編下碼
	client := &http.Client{}
	req, _ := http.NewRequest("POST", "https://api.ihuyi.com/ocr/Submit.json", body)

	req.Header.Set("Content-Type", "application/x-www-form-urlencoded;")
	//fmt.Printf("%+v\n", req) //看下發(fā)送的結(jié)構(gòu)

	resp, err := client.Do(req) //發(fā)送
	defer resp.Body.Close()     //一定要關(guān)閉resp.Body
	data, _ := ioutil.ReadAll(resp.Body)
	fmt.Println(string(data), err)
}

現(xiàn)在注冊,即享新用戶禮包!

在線咨詢
電話咨詢

服務(wù)熱線:

4008 808 898

服務(wù)熱線(工作時間):

4008 808 898

業(yè)務(wù)咨詢(非工作時間):

售后咨詢(非工作時間):

驗證碼已發(fā)送到您的手機,請查收!

輸入驗證碼后,點擊“開通體驗賬戶”按鈕可立即開通體驗賬戶。

收不到短信驗證碼?
互億無線不提供接碼服務(wù),接碼用戶請勿點擊開通按鈕。
×