// 接口類型:互億無線OCR識別接口
// 賬戶注冊: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"
_img_base64 := ""
_img_url := "http://www.xx.com/xx.png"
v.Set("account", _account)
v.Set("password", GetMd5String(_account + _password + _now))
v.Set("img_base64", _img_base64)
v.Set("img_url", _img_url)
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/orc/idcard/Submit.json", body)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded;")
//fmt.Printf("%+v", req) //看下發(fā)送的結構
resp, err := client.Do(req) //發(fā)送
defer resp.Body.Close() //一定要關閉resp.Body
data, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(data), err)
}
驗證碼已發(fā)送到您的手機,請查收!
輸入驗證碼后,點擊“開通體驗賬戶”按鈕可立即開通體驗賬戶。