发送短信
请求
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"}