基于来信码的短信通知平台

项目描述:

  在企业日常运营中总有一些需要定期提醒或者异常情况预警的需求,为此我们需要做一个短信通知平台。

功能描述:

  根据具体的业务需要开发程序,当需要提醒或者预警的情况发生时程序将被触发通过调用第三方短信平台的API来发送相关消息给相关人员。

来信码短信平台API调用代码示例:

 1 namespace ShortMsg
 2 {
 3     public class BechSms
 4     {
 5         public static readonly string Url = "http://imlaixin.cn/Api/send/data/json";
 6         public string Accesskey { get; set; }
 7         public string Secretkey { get; set; }
 8 
 9         public BechSms(string access, string secret)
10         {
11             this.Accesskey = access;
12             this.Secretkey = secret;
13         }
14 
15         public string Send(string mobile, string msg)
16         {
17             string param = "accesskey=" + this.Accesskey + "&secretkey=" + this.Secretkey + "&mobile=" + mobile + "&content=" + msg;
18             return Request(BechSms.Url, param);
19         }
20 
21         private string Request(string url, string param)
22         {
23             string strURL = url + '?' + param;
24             System.Net.HttpWebRequest request;
25             request = (System.Net.HttpWebRequest)WebRequest.Create(strURL);
26             request.Method = "GET";
27             System.Net.HttpWebResponse response;
28             response = (System.Net.HttpWebResponse)request.GetResponse();
29             System.IO.Stream s;
30             s = response.GetResponseStream();
31             string StrDate = "";
32             string strValue = "";
33             StreamReader Reader = new StreamReader(s, Encoding.UTF8);
34             while ((StrDate = Reader.ReadLine()) != null)
35             {
36                 strValue += StrDate + "\r\n";
37             }
38             return strValue;
39         }
40     }
41 }

 

posted @ 2017-12-06 13:24  M守护神  阅读(916)  评论(0编辑  收藏  举报