文档中心

新手指南 / 服务介绍 / 接口说明 / 代码示例 / 注意事项

c#

示例中验证部分username固定为api,password格式为key-32位KEY,各位的KEY可在后台短信或语音->触发发送下查看、更改

发送短信
发送语音

发送短信

请求
string mobile = "18602112512",
message = "Test send message use luosimao!【铁壳测试】",
username = "api",
password = "key-b2652cf62f07dd09a4d561dcb4528032",
url = "http://sms-api.luosimao.com/v1/send.json";

byte[] byteArray = Encoding.UTF8.GetBytes("mobile=" + mobile + "&message=" + message);
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(new Uri(url));
string auth = "Basic " + Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(username + ":" + password));
webRequest.Headers.Add("Authorization", auth);
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.ContentLength = byteArray.Length;

Stream newStream = webRequest.GetRequestStream();
newStream.Write(byteArray, 0, byteArray.Length);
newStream.Close();

HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
StreamReader php = new StreamReader(response.GetResponseStream(), Encoding.Default);
string Message = php.ReadToEnd();

System.Console.Write(Message);
System.Console.Read();

 

返回结果
{"error":0,"msg":"ok"}

 

获取余额

请求
string linkUrl = "http://sms-api.luosimao.com/v1/status.json",
username = "api",
password = "key-b2652cf62f07dd09a4d561dcb4528032"; //api key

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(linkUrl);
string auth = "Basic " + Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(username + ":" + password));
request.Headers.Add("Authorization", auth);

HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader respStream = new StreamReader(response.GetResponseStream());
System.Console.Write(respStream.ReadToEnd());
System.Console.Read();

 

返回结果
{"error":0,"deposit":"123"}

发送语音

请求
string mobile = "18602112512",
code = "123456",
username = "api",
password = "key-b2652cf62f07dd09a4d561dcb4528032",
url = "http://voice-api.luosimao.com/v1/verify.json";

byte[] byteArray = Encoding.UTF8.GetBytes("mobile=" + mobile + "&code=" + code);
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(new Uri(url));
string auth = "Basic " + Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(username + ":" + password));
webRequest.Headers.Add("Authorization", auth);
webRequest.Method = "POST";
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.ContentLength = byteArray.Length;

Stream newStream = webRequest.GetRequestStream();
newStream.Write(byteArray, 0, byteArray.Length);
newStream.Close();

HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
StreamReader php = new StreamReader(response.GetResponseStream(), Encoding.Default);
string Message = php.ReadToEnd();

System.Console.Write(Message);
System.Console.Read();

 

返回结果
{"error":0,"msg":"ok"}

 

获取余额

请求
string linkUrl = "http://voice-api.luosimao.com/v1/status.json",
username = "api",
password = "key-b2652cf62f07dd09a4d561dcb4528032"; //api key

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(linkUrl);
string auth = "Basic " + Convert.ToBase64String(System.Text.Encoding.Default.GetBytes(username + ":" + password));
request.Headers.Add("Authorization", auth);

HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader respStream = new StreamReader(response.GetResponseStream());
System.Console.Write(respStream.ReadToEnd());
System.Console.Read();

 

返回结果
{"error":0,"deposit":"123"}
微信客服
立即咨询
客服热线:
021-60193106
服务时间:
9:00-18:00
(周日除外)