This topic provides a demo to describe how to use Alibaba Cloud SDK for Go to call the SendMessageToGlobe operation. This API operation allows you to send messages to the countries or regions outside the Chinese mainland.

Usage notes

  • You must set the regionId parameter to ap-southeast-1.
  • You must set the domain parameter to dysmsapi.ap-southeast-1.aliyuncs.com.
  • You must set the version parameter to 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())
}