This topic describes how to use SMS SDK for C# to call the QueryMessage operation. This API operation allows you to query the statuses of text messages.
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
MessageId | String | Yes | 1008***3003003 | The ID of the text message. |
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
ResponseCode | String | OK | The status that indicates whether the message sending request was submitted. |
ResponseDescription | String | The SMS Send Request was accepted | The detailed description of the status that indicates whether the message sending request was submitted. |
To | String | 6581177810 | The mobile phone number that received the text message. |
Status | Number | 1 | The status that indicates whether the text message was sent.
|
ErrorCode | String | DELIVERED | The status code that indicates whether the text message was sent. |
ErrorDescription | String | success | The description of the status code that indicates whether the text message was sent. |
Message | String | Hello! | The content of the text message. |
SendDate | String | Mon, 24 Dec 2018 16:58:22 +0800 | The time when the text message was sent to the carrier. |
ReceiveDate | String | Mon, 24 Dec 2018 16:58:22 +0800 | The time when the delivery receipt was received from the carrier. |
NumberDetail | String | The details of the mobile phone number. | |
└Country | String | Hongkong, China | The country to which the mobile phone number belongs. |
└Region | String | HongKong | The region to which the mobile phone number belongs. |
└Carrier | String | CMI | The carrier that provides the mobile phone number. |
Install the core library of Alibaba Cloud SDK for C#
- Method 1: Use the NuGet package manager. For more information, see Installation guide.
- Method 2: Click Alibaba Cloud SDK for C# to download the core library of Alibaba Cloud SDK for C#.
Sample requests
- When you initialize the IClientProfile class, the value of the regionId parameter must be ap-southeast-1 and cannot be modified.
- You must set the domain parameter to dysmsapi.ap-southeast-1.aliyuncs.com.
- You must set the version parameter to 2018-05-01.
using System;
using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Profile;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.Core.Http;
namespace CommonRpc
{
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
{
Method = MethodType.POST,
Domain = "dysmsapi.ap-southeast-1.aliyuncs.com",
Version = "2018-05-01",
Action = "QueryMessage"
};
// request.Protocol = ProtocolType.HTTPS;
request.AddQueryParameters("MessageId", "140101545641902498");
try
{
CommonResponse response = client.GetCommonResponse(request);
Console.WriteLine(response.Data);
}
catch (ServerException e)
{
Console.WriteLine(e);
}
catch (ClientException e)
{
Console.WriteLine(e);
}
}
}
}