使用ASP.NET MVC C#的SMS API [英] SMS API using ASP.NET MVC C#

查看:71
本文介绍了使用ASP.NET MVC C#的SMS API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用下面给出的sms api,api详细信息,当我点击发送按钮消息显示消息发送成功但消息无法发送时,请告诉我我哪里错了



1.身份验证&会话ID

为了传递消息,系统需要将请求验证为来自有效源。

以下参数用于实现此目的:



msisdn:这是您公司电话的手机号码&短信帐户

密码:这是您为帐户设置的当前密码

您可以打开多个线程,但会话ID将在30分钟不活动后过期。然后,您必须重新进行身份验证才能收到新的会话ID。



示例:

命令:

https://sms.com:27677/corporate_sms2/api/auth.jsp?msisdn=xxxx&password=xxx



成功回复:

I want to use sms api, api detail given below, when i click on send button message show "Message Send Successfully" but message cannot send, kindly told me where i do mistake

1. Authentication & Session ID
In order to deliver a message, the system needs to authenticate the request as coming from a valid source.
The following parameters are used to achieve this:

msisdn: This is the Mobile Number for your Corporate Call & SMS Account
password: This is the current password you have set for your Account
You can have multiple threads open, however the session ID will expire after 30 minutes of inactivity. You will then have to re-authenticate to receive a new session ID.

Example:
Command:
https://sms.com:27677/corporate_sms2/api/auth.jsp?msisdn=xxxx&password=xxx

Success Response:

<?xml version="1.0" encoding="UTF-8" ?>
<corpsms>
<command>Auth_request</command>
<data>Session ID</data>
<response>OK</response>
</corpsms>





错误响应:



Error Response:

<?xml version="1.0" encoding="UTF-8" ?>
<corpsms>
<command>Auth_request</command>
<data>Error Code</data>
<response>ERROR</response>
</corpsms>



注意:此会话ID必须与API的所有未来命令一起使用。



2.发送快速消息

此命令用于发送快速消息。要发送快速消息,目标地址应采用923xxxxxxxxx格式。所需的基本参数是:



session_id:从身份验证返回的会话ID

到:逗号分隔的目标手机号码列表

text:消息的内容

mask(可选):用于发送消息的掩码。如果此参数不是
,则使用默认掩码

unicode(可选):如果SMS的文本是英语以外的任何语言,参数必须发送到TRUE。

operator_id(可选):如果要通过特定运营商发送SMS,则该字段应该包含相应运营商的ID。

附录D中提到了运营商列表。

每条消息都以消息ID的形式返回唯一标识符。对于多个目标号码,
$ b返回$ b逗号分隔的消息ID列表。为每个手机号码返回单个消息ID。

如果即使单个手机号码格式不正确,该请求也将被拒绝。可以使用消息ID

来跟踪和监控任何给定的消息。每封帖后都会返回消息ID。



示例:

命令:

https:// sms .com:27677 / corporate_sms2 / api / sendsms.jsp?session_id = xxxx& to = 923xxxxxxxxx,923xx

xxxxxxx,923xxxxxxxxx& text = xxxx& mask = xxxx



成功回应:


NOTE: This Session ID must be used with all future commands to the API.

2. Sending a Quick Message
This command is used to send a Quick Message. To send a quick message, the destination address should be in the format 923xxxxxxxxx. The basic parameters required are:

session_id: The session ID returned from authentication
to: Comma separated list of destination mobile numbers
text: The content of the message
mask (optional): The mask to be used to send the message. If this parameter is not
present, then the default mask will be used
unicode (optional): If the text of the SMS is in any language other than English, this parameter must be sent to TRUE.
operator_id (optional): If the SMS is to be sent through a specific operator, this field should
contain ID for the respective operator.
List of operators is mentioned in Appendix D.
Each message returns a unique identifier in the form of Message ID.For multiple destination numbers, a
comma separated list of message ID's is returned. Single message ID is returned for each mobile number.
If even a single mobile number is in incorrect format, the request will be rejected. The message ID can be used
to track and monitor any given message. The message ID is returned after each post.

Example:
Command:
https://sms.com:27677/corporate_sms2/api/sendsms.jsp?session_id=xxxx&to=923xxxxxxxxx,923xx
xxxxxxx,923xxxxxxxxx&text=xxxx&mask=xxxx

Success Response:

<?xml version="1.0" encoding="UTF-8" ?>
<corpsms>
<command>Submit_SM</command>
<data>Message ID1,Message ID2,Message ID3</data>
<response>OK</response>
</corpsms>
Error Response:
<?xml version="1.0" encoding="UTF-8" ?>
<corpsms>
<command>Submit_SM</command>
<data>Error Code</data>
<response>ERROR</response>
</corpsms>





我的尝试:





What I have tried:

[HttpPost]
 public string SendSMS(string strNumber, string strMessage)
 {
   string Result = string.Empty;
   var plaintext = GetPlainTextFromHtml(strMessage);
WebRequest request = WebRequest.Create("https://sms.com:27677/corporate_sms2/api/sendsms.jsp?msisdn=SimNumber&password=PWD&to="+strNumber+"&text="+plaintext+"&mask=Masking Name");
            request.Method = "POST";
            //request.ContentType = "text/xml";
            request.ContentType = "text/xml;charset=UTF-8";
            //request.ContentType = "application/x-www-form-urlencoded";
            WebResponse response = request.GetResponse();
            if (((HttpWebResponse)response).StatusDescription.Equals("OK"))
            {
                Result = "Message Send Successfully";

            }
            response.Close();
            //var result;
            return Result;
        }

推荐答案





你能查一下吗? Sms.com API文档,无论是GET还是POST。如果发布,则必须更改上述逻辑。
Hi ,

Can you check the Sms.com API documentation whether this is GET or POST. If post then you have to change the above logic.


这篇关于使用ASP.NET MVC C#的SMS API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆