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

项目描述:

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

功能描述:

  根据具体的业务需要开发程序,当需要提醒或者预警的情况发生时程序将被触发通过调用第三方短信平台的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 @   M守护神  阅读(935)  评论(0编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· [AI/GPT/综述] AI Agent的设计模式综述
点击右上角即可分享
微信分享提示