欢迎使用SMN服务Go SDK。SMN服务Go SDK 能简化你使用SMN服务的复杂程度。这里向您介绍如何使用Go SDK 并开始调用。
使用go get下载安装SDK
go get -u github.com/SimpleMessageNotification/smn-sdk-go/smn-sdk-go
以下这个代码示例向您展示了调用SMN服务SDK 的 3 个主要步骤:
package main import ( "github.com/smn-sdk-go/smn-sdk-go/client" "fmt" ) func main() { // init client, you can init client only once smnClient, err := client.NewClient( "YourAccountUserName", "YourAccountDomainName", "YourAccountPassword", "YourRegionName") if err != nil { panic(err) } request := smnClient.NewSmsPublishRequest() request.EndPoint = "+86136*****587" request.SignId = "6be340e91e524******85837e6709104" request.Message = "您的验证码是:1234,请查收" response, err := smnClient.SmsPublish(request) if err != nil { fmt.Println("the request is error ", err) return } if !response.IsSuccess() { fmt.Printf("%#v\n", response.ErrorResponse) return } fmt.Printf("%#v\n", response) }
API或输入参数相关问题,请查阅API文档