// 接口类型:互亿无线实名认证接口
// 账户注册: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 := "bank4"//固定值
_name := "张三"
_id_card_no := "123456789012345678"
_mobile := "13600000000"
_bank_card_no := "637556789"
v.Set("account", _account)
v.Set("password", GetMd5String(_account+_password+_app+_name+_id_card_no+_mobile+_bank_card_no+_now))
v.Set("app", _app)
v.Set("name", _name)
v.Set("id_card_no", _id_card_no)
v.Set("mobile", _mobile)
v.Set("bank_card_no", _bank_card_no)
v.Set("time", _now)
//body := ioutil.NopCloser(strings.NewReader(v.Encode())) //把form数据编下码
body := strings.NewReader(v.Encode()) //把form数据编下码
client := &http.Client{}
req, _ := http.NewRequest("POST", "https://api.ihuyi.com/idcard/Submit.json", body)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded;")
//fmt.Printf("%+v\n", req) //看下发送的结构
resp, err := client.Do(req) //发送
defer resp.Body.Close() //一定要关闭resp.Body
data, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(data), err)
}
验证码已发送到您的手机,请查收!
输入验证码后,点击“开通体验账户”按钮可立即开通体验账户。