附近小店
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 2 месеца
12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package weapp
  2. const (
  3. apiFaceIdentify = "/cityservice/face/identify/getinfo"
  4. )
  5. // FaceIdentifyResponse 人脸识别结果返回
  6. type FaceIdentifyResponse struct {
  7. CommonError
  8. Result int `json:"identify_ret"` // 认证结果
  9. Time uint32 `json:"identify_time"` // 认证时间
  10. Data string `json:"validate_data"` // 用户读的数字(如是读数字)
  11. OpenID string `json:"openid"` // 用户openid
  12. UserIDKey string `json:"user_id_key"` // 用于后台交户表示用户姓名、身份证的凭证
  13. FinishTime uint32 `json:"finish_time"` // 认证结束时间
  14. IDCardNumberMD5 string `json:"id_card_number_md5"` // 身份证号的md5(最后一位X为大写)
  15. NameUTF8MD5 string `json:"name_utf8_md5"` // 姓名MD5
  16. }
  17. // FaceIdentify 获取人脸识别结果
  18. //
  19. // token 微信 access_token
  20. // key 小程序 verify_result
  21. func FaceIdentify(token, key string) (*FaceIdentifyResponse, error) {
  22. api := baseURL + apiFaceIdentify
  23. return faceIdentify(api, token, key)
  24. }
  25. func faceIdentify(api, token, key string) (*FaceIdentifyResponse, error) {
  26. api, err := tokenAPI(api, token)
  27. if err != nil {
  28. return nil, err
  29. }
  30. params := requestParams{
  31. "verify_result": key,
  32. }
  33. res := new(FaceIdentifyResponse)
  34. err = postJSON(api, params, res)
  35. if err != nil {
  36. return nil, err
  37. }
  38. return res, nil
  39. }