Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the C # SMS interface

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article is about how to use the c # SMS interface. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

SMS sending API 1.1 request address

The request address is the url address requested when the client interface program is called, using the https post interface, and the address is

Https://sh3.ipyy.com/sms.aspx corresponds to UTF-8

Https://sh3.ipyy.com/smsGBK.aspx corresponds to GB2312

Https://sh3.ipyy.com/smsJson.aspx corresponds to UTF-8 (return value is in json format)

Https://sh3.ipyy.com/ensms.ashx corresponds to UTF-8 (encrypted transmission, using json)

Generally speaking, the entry address will not change, and when there is a change, the interface user will be notified.

1.2 Parameter description

Parameter name

Meaning

Description

Userid

Enterprise id

Enterprise ID (not verified)

Account

Send user account number

User account number, by system administrator

Password

Send account password

The password corresponding to the user account

You can use plaintext or all md5 encryption. Md5 is 32-bit uppercase.

For example, after abc123 encryption,

E99A18C428CB38D5F260853678922E03

Mobile

All dialed numbers

The destination number to which the message is sent. Multiple numbers are separated by half-width commas

Content

Send content

The content of the SMS message needs to be encoded by UTF-8, and the submitted content format: content + [signature]. Signature is the name of the company or the name of the company project. Example: your CAPTCHA: 1439 [take off]. [] is the identifier of the signature. Please submit the content test according to the formal format

SendTime

Timing sending time

If it is empty, it means to send immediately. The timing format is 2010-10-24 09:08:10.

Action

Send task command

Set to fixed: send

Extno

Extended subnumber

Please first ask whether the configured channel supports extended subnumbers. If not, please fill in the blanks. Subnumbers can only be numbers and up to 5 digits.

For example:

Https://sh3.ipyy.com/sms.aspx?action=send&userid=&account= account & password= password & mobile=15023239810,13527576163&content= content & sendTime=&extno=

1.3 return value

After receiving the https request sent by the client, the processing result is returned in the form of xml. The format is:

Status-return status value: successful return Success failed return: Faild

Message-related error description

Remainpoint-returns the balance

TaskID-returns the sequence ID of this task

SuccessCounts-number of successful SMS messages: returns the number of successful SMS messages submitted when successful

1.4 Json return value

{"returnstatus": "Success"

"message": "Operation succeeded"

Remainpoint: "- 4"

"taskID": "1504080852350206"

"successCounts": "1"}

The following is the demo of the c # SMS interface

/ / Huaxin SMS DEMO program (aspx API)

/ / Free test of SMS verification code: 17721077856 2885400276

/ / Development environment: vs2015,.net framework 4.0, Microsfot Http Client 2.2.29

/ / version: 1.1

/ / Last revision: 2016-12-28

Using System

Using System.Collections.Generic

Using System.Net.Http

Using System.Xml.Linq

Using System.Xml.XPath

Namespace Huaxin.MessageSend.Demo

{

Class SendViaAspx: ISender

{

Private const string URL = @ "https://sh3.ipyy.com/sms.aspx";

Private readonly HttpClient _ client = new HttpClient ()

Public SendViaAspx ()

{

_ client.DefaultRequestHeaders.Clear ()

_ client.BaseAddress = new Uri (URL)

}

Public void DoSend ()

{

Var accountName = "yzz"; / / change to the actual account name

Var password = "yzz123"; / / change to the actual send password

Var mobiles = "18611729367"; / / multiple mobile phone numbers are separated by ","

Var content = "C # version aspx API sends test, your CAPTCHA: 8888 [Huaxin]"

Var extNumber = ""

Var result = GetResult (accountName, password, mobiles, content, extNumber)

Print (result)

}

Private string GetResult (string accountName, string password,string mobiles, string content, string extNumber)

{

Var req = new HttpRequestMessage ()

Req.Headers.Clear ()

Req.Headers.Add ("ContentType", "application/x-www-form-urlencoded;charset=utf-8")

Req.Method = HttpMethod.Post

Req.Content = new FormUrlEncodedContent (new Dictionary

{

{"action", "send"}

{"userid", ""}

{"account", accountName}

{"password", password}

{"mobile", mobiles}

{"content", content}

{"sendtime", ""}

{"extno", extNumber}

});

Var response = _ client.SendAsync (req) .Result

Try

{

Response.EnsureSuccessStatusCode ()

}

Catch (Exception ex)

{

Console.WriteLine ("Error: {0}", ex.Message)

Return ""

}

Return response.Content.ReadAsStringAsync () Result

}

Private void Print (string resultString)

{

Var el = XElement.Parse (resultString)

Var root = el.XPathSelectElement ("/")

Var status = root.XPathSelectElement ("returnstatus") .Value

Var message = root.XPathSelectElement ("message") .Value

Var remainpoint = root.XPathSelectElement ("remainpoint") .Value

Var taskid = root.XPathSelectElement ("taskID") .Value

Var successCounts = root.XPathSelectElement ("successCounts") .Value

Console.WriteLine (status: {0}, status)

Console.WriteLine ("status description: {0}", message)

Console.WriteLine ("balance: {0}", remainpoint)

Console.WriteLine ("Task ID: {0}", taskid)

Console.WriteLine ("number of successes: {0}", successCounts)

}

}

}

Thank you for reading! This is the end of the article on "how to use the c # SMS interface". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report