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

Usage notes

  • When you define a new default profile, the value of the regionId parameter must be ap-southeast-1 and cannot be changed. Note that regionId is the first parameter in the default profile.
  • 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

using System;
using System.Collections.Generic;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Profile;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.Core.Http;

namespace CommonRequestDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            IClientProfile profile = DefaultProfile.GetProfile("ap-southeast-1", "<accessKeyId>", "<accessSecret>");
            DefaultAcsClient client = new DefaultAcsClient(profile);
            CommonRequest request = new CommonRequest();
            request.Method = MethodType.POST;
            request.Domain = "sms-intl.ap-southeast-1.aliyuncs.com";
            request.Version = "2018-05-01";
            request.Action = "BatchSendMessageToGlobe";
            // request.Protocol = ProtocolType.HTTP;

            try {
                CommonResponse response = client.GetCommonResponse(request);
                Console.WriteLine(System.Text.Encoding.Default.GetString(response.HttpResponse.Content));
            }
            catch (ServerException e)
            {
                Console.WriteLine(e);
            }
            catch (ClientException e)
            {
                Console.WriteLine(e);
            }
        }
    }
}