点击这里给我发消息
帮助中心

工作时间:8:30 - 17:30

GO

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 := "帐号"
    _password := "接口密码"
    _mobile := "158xxxxxxxx"
    _content := "您的订单编码:4557。如需帮助请联系客服。"
    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 := ioutil.NopCloser(strings.NewReader(v.Encode())) //把form数据编下码
    client := &http.Client{}
    req, _ := http.NewRequest("POST", "http://sms.106jiekou.com/utf8/sms.aspx", body)
 
    req.Header.Set("Content-Type", "application/x-www-form-urlencoded; param=value")
    //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)
}