//接口類型:互億無線國際短信接口。
//賬戶注冊:請通過該地址開通賬戶https://user.ihuyi.com/new/register.html
//注意事項:
//(1)調(diào)試期間,請仔細閱讀接口文檔;
//(2)請使用 APIID 及 APIKEY來調(diào)用接口,可在會員中心獲取;
//(3)該代碼僅供接入互億無線短信接口參考使用,客戶可根據(jù)實際需要自行編寫;
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 := "cf_xxxxxxx" //查看用戶名 登錄用戶中心->國際驗證碼>產(chǎn)品總覽->API接口信息->APIID
_password := "xxxxxxxxxxxxxxxxxxxxxxxxxxxxx" //查看密碼 登錄用戶中心->國際驗證碼>產(chǎn)品總覽->API接口信息->APIKEY
_mobile := "136xxxxxxxx"
_content := "Your verification code is 1125"
v.Set("account", _account)
v.Set("password", GetMd5String(_account+_password+_mobile+_content+_now))
v.Set("mobile", _mobile)
v.Set("content", _content)
v.Set("time", _now)
body := strings.NewReader(v.Encode()) //把form數(shù)據(jù)編下碼
client := &http.Client{}
req, _ := http.NewRequest("POST", "http://api.isms.ihuyi.com/webservice/isms.php?method=Submit&format=json", body)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded; param=value")
//fmt.Printf("%+v\n", req) //看下發(fā)送的結(jié)構(gòu)
resp, err := client.Do(req) //發(fā)送
defer resp.Body.Close() //一定要關(guān)閉resp.Body
data, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(data), err)
}
驗證碼已發(fā)送到您的手機,請查收!
輸入驗證碼后,點擊“開通體驗賬戶”按鈕可立即開通體驗賬戶。