苹果签名

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

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

admin5个月前 (12-19)苹果签名111

  悠逸企业短信发送服务,是一种比较简单易操作的短信发送服务,使用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

分享给朋友:

相关文章

【光程科技】做苹果tf签名前务必了解的三点

【光程科技】做苹果tf签名前务必了解的三点

  根据苹果方面的规定,tf上架完成APP上架至testflight后,是有最多三个月的有效期。也就是说,在上架testflight之后,苹果官方生成的下载链接的有效期是三个月,过来有效期则链接会失效...

Code Signing Resources

Code Signing Resources

  This site contains user submitted content, comments and opinions and is for informational purposes...

苹果证书签名失败

苹果证书签名失败

  苹果证书签名失败是指在iOS开发过程中,使用Xcode进行应用程序打包或部署到设备上时,出现了签名失败的情况。下面将对苹果证书签名失败的原理进行详细介绍。   在iOS开发中,为了保证iOS...

苹果手机邮件怎么设置签名?iPhone邮件签名设置教程

苹果手机邮件怎么设置签名?iPhone邮件签名设置教程

  在苹果手机中有自带邮件,我们可以通过该邮件进行各好友联系,那么在邮件中该如何设置签名?以下是设置方法,希望能够帮到你。   iPhone邮件签名设置教程   点击手机桌面“设置”打开,...

苹果ipa签名工具免越狱下载_7233游戏盒苹果版下载-7233游戏盒苹果免越狱手机版下载v4.0.0...

苹果ipa签名工具免越狱下载_7233游戏盒苹果版下载-7233游戏盒苹果免越狱手机版下载v4.0.0...

  7233游戏盒苹果版APP是一款支持多种好玩游戏资源的娱乐盒子软件。在这里让你自由搜索资源,想玩的在这里统统免费来玩,还可以让你在这里寻找宝盒,拥有超多的游戏特权等。快来下载玩吧。   72...

ipa苹果企业签名怎么弄的?

ipa苹果企业签名怎么弄的?

  在iOS设备上,通过App Store下载并安装应用程序是很常见的操作。然而,有时我们可能需要下载一些未经App Store审核的应用程序,或者基于企业的需求,需要在内部分发应用程序。   ...

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

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