TP5 百度AI身份證識別

2021-10-21 19:44:51 字數 1980 閱讀 5323

//身份證認證

public

function

code()

//給予錯誤資訊if(

$res

['image_status']!=

'normal')}

if($res

['idcard_number_type']!=

1)}//如果沒有該使用者存到資料庫

$data=[

'user_id'

=>

$this

->

uid,

'realname'

=>

$res

['words_result'][

'姓名'][

'words'],

'id_card'

=>

$res

['words_result'][

'公民身份號碼'][

'words'],

'jsoninfo'

=>

$re,

'createtime'

=>

time()

,'updatetime'

=>

time()

,];if

(db('user_autonym')-

>

insert

($data)==

false

)return

$this

->

success

('認證成功!');

}

//發起http post請求(rest api), 並獲取rest請求的結果

function

request_post

($url=''

,$param=''

)$posturl

=$url

;$curlpost

=$param

;// 初始化curl

$curl

=curl_init()

;curl_setopt

($curl

,curlopt_url

,$posturl);

curl_setopt

($curl

,curlopt_header,0

);// 要求結果為字串且輸出到螢幕上

curl_setopt

($curl

,curlopt_returntransfer,1

);curl_setopt

($curl

,curlopt_ssl_verifypeer

,false);

// post提交方式

curl_setopt

($curl

,curlopt_post,1

);curl_setopt

($curl

,curlopt_postfields

,$curlpost);

// 執行curl

$data

=curl_exec

($curl);

curl_close

($curl);

return

$data

;}

成功後獲取到的內容

},

"民族":}

,"住址":}

,"公民身份號碼":}

,"出生":}

,"性別":}

},"log_id"

:xx,

"words_result_num"

:xx,

"idcard_number_type"

:xx,

"image_status"

:"normal"

}

使用百度ai識別身份證資訊

python 3.5 安裝python sdk pip install baidu ai from aip import aipocr 你的 api key secretkey 你的 secret key 系統分配給使用者的,均為字串,用於標識使用者,為訪問做簽名驗證,可在ai服務控制台中的應用列表...

百度api識別身份證資訊

有上述功能。params id card side front urlencoder.encode image utf 8 urlencoder.encode base64imgstr,utf 8 2.token的獲取直接上 獲取token位址 string authhost string geta...

Python呼叫百度AI實現身份證識別

目錄 按win r開啟cmd,在裡面輸入 若出現如下介面,即成功安裝了baidu aip模組 如果想快速了解識別營業執照 原理,可以跳過第二部分,先看第三部分的內容。在應用python識別身份證的過程中,有三行 使用了ai介面金鑰,故先闡述如何獲得該金鑰。首先,進入如下ai官方 有賬戶的輸入賬戶密碼...