程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Face core app access - server Python demo

編輯:Python

Preface : Access the face core APP when , It needs to involve the development of multiple back-end interfaces , but The official website document of the human face core There is no complete code example , This article provides an example based on Python A complete example of the server of .

One 、 Overall access process

1、 Interfaces and documents involved

Backend involves 5 Interface ;App It's relatively simple , Use the order number obtained from the back end 、 Signature and other information call SDK that will do .

Server side

Serial number

Content

remarks

1

Time acquisition Access Token

Interface document

2

according to Access Token obtain sign ticket

Interface document

3

The partner sends the identity information to the background : Based on user information and sign ticket Generated signature , obtain faceId( Unique identification of the user who brushes the face ) Wait to start SDK Parameters of

Interface document

4

according to Access Token obtain nonce ticket, Generate sign

Interface document

5

Provide a web Service supply APP The client obtains the above 3、4 The call generated in step SDK Parameters of

6

Server verification results

Interface document

APP End

Serial number

Content

remarks

1

launch http Request to obtain the signature and other parameters generated by the server

2

Start the kernel using the request parameters obtained by the server SDK

Interface document

App For example, please refer to this article : Face nucleus APP Access -Android Server-side implementation

Explanation of confusing terms :

Access Token:

     The period of validity 2 Hours , Suggest every 20 Minutes to request new , The coexistence of the old and the new 1 minute .

     Use scenarios : obtain sign ticket.

sign ticket:

    The period of validity 60 minute , Recommendations and Access Token Bind refresh .

    Use scenarios : The partner sends the identity information to the background .

nonce ticket:

     The period of validity 120 second , One time .

     Use scenarios : start-up SDK face scan .

2、 Refer to the access flow chart

(H5 Access flow chart for reference )

Two 、 Example demo

1、 Example demo Project package

wbface.zip

2、demo Usage method

Refer to the compressed package README file

Dependency Library :

Flask、requests

Usage mode :

1、 stay config.py Fill in the wbappid、secret

Console address :https://console.cloud.tencent.com/faceid/access

2、 Background operation flush_access_token.py

Refresh regularly access_token and sign_ticket.

( Recommended order :nohup python -u flush_access_token.py > flush_access_token.log 2>&1 &)

3、 function web_server.py start-up 2 individual web service :

http://xxx/get_face_params for APP The client gets the order signature and so on SDK Parameters of

http://xxx/get_result Used to obtain validation results

( Recommended order :nohup python -u web_server.py > web_server.log 2>&1 &)

web Detailed description of the service :

function web_server.py after , Console or log The file will print web Service address

Client request protocol : The request method is POST, Request header Content-Type Need to be ‘application/x-www-form-urlencoded’

http://xxx/get_face_params Example of service input :{'name': ' Xiao Ming ', 'id_no': '4311120022232323'}

http://xxx/get_result Example of service input :{'order_no': 'xxxx'}


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved