本文为您提供了Go语言版本的提交查询接口对接DEMO示例
//测试:go run ./test.go
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strings"
)
const strUrl = "https://api.ihuyi.com/idcard/id3/Submit.json"
func main() {
v := url.Values{}
v.Set("account", "xxxxxxxx") //APIID(用户中心【认证核验】-【身份信息验证】-【产品总览】查看)
v.Set("password", "xxxxxxxxx") //1、APIKEY(用户中心【认证核验】-【身份信息验证】-【产品总览】查看)
2、动态密码(生成动态密码方式请看该文档末尾的说明)
v.Set("name", "张三") //身份证姓名
v.Set("id_card_no", "40122111******") //身份证号码
v.Set("faceFile", "**.jpg") //使用参数,内容格式需要改为:Content-Type: multipart/form-data 上传人像图片文件,大小为5KB-1MB 格式为jpg、jpeg、png、bmp(faceFile、faceUrl、faceBase64三选一传递)
v.Set("faceUrl", "http://img.aa.com/demo.jpg") //人像图片网址(faceFile、faceUrl、faceBase64三选一传递)
v.Set("faceBase64", "******") //图片内容的Base64,如使用Base64,faceFileType为必填(faceFile、faceUrl、faceBase64三选一传递)
v.Set("faceFileType", "jpg") //faceBase64图片的文件格式:jpg、jpeg、png、bmp
v.Set("time", "1623643787") //Unix时间戳(10位整型数字,当使用动态密码方式时为必填)
body := strings.NewReader(v.Encode()) //把form数据编码
client := &http.Client{}
req, _ := http.NewRequest("POST", strUrl, body)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
resp, err := client.Do(req) //发送
if err != nil {
fmt.Println(err)
}
defer resp.Body.Close() //一定要关闭resp.Body
res, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(res))
}
在线咨询
150,000家
企业客户
21年
行业经验
2V1
2对1客户支持