短信营销 - 代码示例 * * * * * [[PHP](sms/PHP.md)][[JAVA](sms/JAVA.md)][[ASP](sms/ASP.md) [[ASP.NET(C#)](sms/ASPNET.md)][[JSP](sms/JSP.md)][[C](sms/C.md)][[C++](sms/C++.md)][[GO](sms/GO.md)][[PYTHON](sms/PYTHON.md)][[VB6](sms/VB6.md)] GO代码示例 ~~~ // 接口类型:企讯云营销短信接口,支持发送会员营销短信。 // 接口地址:http://service.qixunpush.com/sendSMS // 账户注册:请联系客服开通账户 // 注意事项: //(1)调试期间,请仔细阅读接口文档; //(2)请使用 account 及 password 来调用接口,可联系客服获取; //(3)该代码仅供接入企讯云短信接口参考使用,客户可根据实际需要自行编写; 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 := "139xxxxxxxx" _content := "【企讯云】尊敬的会员,您好!新品上市,全场3折起!敬请关注。退订回TD" 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://service.qixunpush.com/sendSMS", 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) } ~~~