苹果签名

iphoneqm
首页 > 苹果签名 > 正文内容

c#简单易用的短信发送服务 悠逸企业短信服务

admin6个月前 (12-19)苹果签名150

  悠逸企业短信发送服务,是一种比较简单易操作的短信发送服务,使用POST的方式,请求相应地址就可以实现短信发送功能

c#简单易用的短信发送服务 悠逸企业短信服务

  1 ///

  2 /// 短信发送服务

  3 ///

  4 public class ShortMsgHelper

  5 {

  6 ///

  7 /// 短信服务 账号

  8 ///

  9 private static string uid = ConfigurationManager.AppSettings["ShortMSGUid"];

  10 ///

  11 /// 短信服务 密码

  12 ///

  13 private static string pwd = ConfigurationManager.AppSettings["ShortMSGPwd"];

  14 ///

  15 /// 客服 手机号字符串

  16 ///

  17 private static string CustomerServicePhoneList = ConfigurationManager.AppSettings["CustomerServicePhoneList"];

  18 ///

  19 /// 短信服务 签名(短信内容后面加上 此签名 才能发送成功!形式为:【签名内容】)如果不加,则发送无效

  20 ///

  21 private static string ShortMSGSignature = ConfigurationManager.AppSettings["ShortMSGSignature"];

  22 ///

  23 /// 短信服务 开关

  24 /// open:打开 close:关闭

  25 ///

  26 private static string ShortMSGSwitch = ConfigurationManager.AppSettings["ShortMSGSwitch"];

  27

  28 ///

  29 /// 发送短信开放方法

  30 ///

  31 ///

  32 ///

  33 public static bool Send(string msgContent,List pList)

  34 {

  35 //依据短信服务开关

  36 if (ShortMSGSwitch=="close")

  37 {

  38 return false;

  39 }

  40 List phoneList = new List();

  41 if (pList==null||pList.Count==0)

  42 {

  43 phoneList = CustomerServicePhoneList.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList();

  44 }

  45 else

  46 {

  47 phoneList = pList;

  48 }

  49

  50 return SendMobileMsg(uid, pwd, msgContent, phoneList);

  51 }

  52 ///

  53 /// 短信发送

  54 ///

  55 /// 悠逸企业短信ID

  56 /// 悠逸企业短信密码

  57 /// 短信内容

  58 /// 手机号列表

  59 ///

  60 private static bool SendMobileMsg(string uid, string pwd, string msgContent, List destListPhones)

  61 {

  62 try

  63 {

  64 bool result = false;

  65 string strPhones = string.Join(";", destListPhones.ToArray());

  66 strPhones += ";";

  67 var encoding = System.Text.Encoding.GetEncoding("GB2312");

  68

  69 string postData = string.Format("uid={0}&pwd={1}&mobile={2};&msg={3}&dtime=", uid, pwd, strPhones, msgContent + ShortMSGSignature);

  70

  71 byte[] data = encoding.GetBytes(postData);

  72

  73 // 定义 WebRequest

  74 HttpWebRequest myRequest =

  75 (HttpWebRequest)WebRequest.Create("://.smsadmin/smsmarketing/root/api/post_send/");

  76

  77 myRequest.Method = "POST";

  78 myRequest.ContentType = "application/x--form-urlencoded";

  79 myRequest.ContentLength = data.Length;

  80

  81 Stream newStream = myRequest.GetRequestStream();

  82

  83 //发送数据

  84 newStream.Write(data, 0, data.Length);

  85 newStream.Close();

  86

  87 // 得到 Response

  88 HttpWebResponse myResponse = (HttpWebResponse)myRequest.GetResponse();

  89 StreamReader reader = new StreamReader(myResponse.GetResponseStream(), Encoding.Default);

  90 string content = reader.ReadToEnd();

  91

  92 if (content.Substring(0, 1) == "0")

  93 result = true;

  94 else

  95 {

  96 if (content.Substring(0, 1) == "2") //余额不足

  97 {

  98 //"手机短信余额不足";

  99 //TODO

  100 }

  101 else

  102 {

  103 //短信发送失败的其他原因,请参看官方API

  104 }

  105 result = false;

  106 }

  107

  108 return result;

  109 }

  110 catch

  111 {

  112 return false;

  113 }

  114

  115 }

  116 }

扫描二维码推送至手机访问。

版权声明:本文由MDM苹果签名,IPA签名,苹果企业签名,苹果超级签,ios企业签名,iphoneqm.com发布,如需转载请注明出处。

转载请注明出处https://iphoneqm.com/iphoneqm/582.html

分享给朋友:

相关文章

网上下载项目真机遇到的问题Apple Development“ in the build settings editor, or switch to manual

网上下载项目真机遇到的问题Apple Development“ in the build settings editor, or switch to manual

  Showing All Messages   ChooseLocation has conflicting provisioning settings. ChooseLocation is...

苹果TF签名实现步骤 如何实现App苹果TF签名?

苹果TF签名实现步骤 如何实现App苹果TF签名?

  用于苹果手机进行App内部测试的官方方式就是TestFlight了,TestFlight又称为是苹果TF签名,这种方式可以实现App在未正式上架App Store前,进行稳定的ios系统的应用内测...

郑恺获得库克签名iPhone!当面建议一定要继续生产mini机型

郑恺获得库克签名iPhone!当面建议一定要继续生产mini机型

  快科技3月22日消息,苹果上海静安Apple Store零售店昨晚正式开业,苹果CEO蒂姆·库克亲临现场,为新店揭幕。   现场顾客人山人海,排队与库克进行合影留念。   前两天与库克...

苹果签名9封装苹果超级签名企业签名免费分发 杭州

苹果签名9封装苹果超级签名企业签名免费分发 杭州

  1. 请查看以下相关信息,或在上方搜索相关信息。   2. 如您是发布人(tf***5),可以点击刷新信息延长1年有效期(购买刷新券低至0.1元/条),或登录会员中心,管理信息批量刷新信息。...

苹果ipa签名解锁_朋友,iOS签名请了解一下

苹果ipa签名解锁_朋友,iOS签名请了解一下

  关于iOS签名小伙伴们知道多少?我相信您们一定知道的一点就是它是苹果手机上面的某种东西,但是具体是什么,有什么用处各位知道吗?不知道也没关系,小编现在就来告诉您,请您听好了!   一、什么是...

一款app上架苹果应用商店操作流程

一款app上架苹果应用商店操作流程

  在苹果应用商店上架一款app,需要经过以下流程:   1. 注册苹果开发者账号   首先,你需要注册一个苹果开发者账号,这个账号是开发者在苹果平台上发布应用程序的必要条件。若你已经有了...

现在,非常期待与您的又一次邂逅

我们努力让每一次邂逅总能超越期待