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

Precautions

  • When you construct the DefaultProfile class, you must use the default value of the regionId parameter. The default value is ap-southeast-1. Note that regionId is the first parameter in the DefaultProfile class.
  • 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

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);
            }
        }
    }
}