GO如何使用阿里云短信接口实例代码?

Muriel ·
更新时间:2024-11-10
· 697 次阅读

有直接能用的阿里云短信接口代码?



阿里云 GO 阿里 接口

import ( "fmt" "github.com/aliyun/alibaba-cloud-sdk-go/services/dysmsapi" ) func SendAliSMS(number,code string,) { regionid:="cn-hangzhou" accessKeyId:="****" accessKeySecret:="****" signName:="1024问" templateCode:="SMS_224660135" //SMS_116590500 client, err := dysmsapi.NewClientWithAccessKey(regionid, accessKeyId, accessKeySecret) request := dysmsapi.CreateSendSmsRequest() request.Scheme = "https" request.PhoneNumbers = number request.SignName = signName request.TemplateCode = templateCode request.TemplateParam = "{\"code\":\""+code+"\"}" response, err := client.SendSms(request) if err != nil { fmt.Print(err.Error()) } fmt.Printf("response is %#v\n", response) }

需要 登录 后方可回复, 如果你还没有账号请 注册新账号