package controllers
import (
"github.com/astaxie/beego"
"github.com/KenmyZhang/aliyun-communicate"
"fmt"
)
type MessageUserController struct {
beego.Controller
}
func (this *MessageUserController) ShowMsg() {
this.Data["Website"] = "beego.me"
this.Data["Email"] = "astaxie@gmail.com"
var (
gatewayUrl = "http://dysmsapi.aliyuncs.com/"
accessKeyId = "Xw"
accessKeySecret = "fY9T9TmHeOuP"
phoneNumbers = "18****08"
signName = "项目名称"
templateCode = "SMS_149101793"
templateParam = "{\"code\":\"wilson\"}"
)
smsClient := aliyunsmsclient.New(gatewayUrl)
result, err := smsClient.Execute(accessKeyId, accessKeySecret, phoneNumbers, signName, templateCode, templateParam)
fmt.Println("Got raw response from server:", string(result.RawResponse))
if err != nil {
beego.Info("配置有问题")
}
if result.IsSuccessful() {
this.Data["result"] = "短信已经发送"
} else {
this.Data["result"] = "短信发送失败"
}
this.TplName = "SMS.html"
}
beego发送短信
最新推荐文章于 2024-10-08 04:07:28 发布