This topic describes how to use the Go SendMessageToGlobe to send SMS messages to users across international regions.

Precautions

  • You must use the default value of the RegionId parameter: ap-southeast-1.
  • You must use the default value of the Domain parameter: dysmsapi.ap-southeast-1.aliyuncs.com.
  • You must use the default value of the Version parameter: 2018-05-01.

Sample code

package main

import (
    "fmt"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk/requests"
)

func main() {
    client, err := sdk.NewClientWithAccessKey("ap-southeast-1", "<accessKeyId>", "<accessSecret>")
    if err ! = nil {
        panic(err)
    }

    request := requests.NewCommonRequest()
    request.Method = "POST"
    request.Scheme = "https" // https | http
    request.Domain = "dysmsapi.ap-southeast-1.aliyuncs.com"
    request.Version = "2018-05-01"
    request.ApiName = "BatchSendMessageToGlobe"
  request.QueryParams["RegionId"] = "ap-southeast-1"

    response, err := client.ProcessCommonRequest(request)
    if err ! = nil {
        panic(err)
    }
    fmt.Print(response.GetHttpContentString())
}