NET 阿里大于短信推送
来源:互联网 发布:联合证券股票交易软件 编辑:程序博客网 时间:2024/05/21 06:24
最近再做一个商城,需要短信推送,研究了下阿里大于的短信推送。
注册,登陆啥的 就不说了 。注册好像分商家和个人。(这里吐槽下。商家真是幸福,短信模板都建好了,个人的居然毛也没有!)
注册成功以后需要建一个应用(需要审核 ),然后建短信模板(需要审核),然后就可以愉快的测试了 。
下载一个SDK文件, 然后添加到自己的工程里面。(这些都是废话)
因为官方给的例子 里面 只有测试的样本 ,所以这里自己封装了下,参数读取配置文件
/// <summary> /// 发送短信 /// </summary> /// <param name="destination">电话号码</param> /// <param name="text">阿里的签名,短信参数-参数值-参数-参数值,模板编码</param> /// <returns></returns> private string SendMessage(string destination, string text, string speed = "0") { if (!string.IsNullOrWhiteSpace(destination)) { MessageSMSConfig config = SMSCore.GetConfig(); string[] textArr = text.Split(new char[] { ',' }); string strQM = textArr[0];//签名 string strCSARR = textArr[1];//参数信息 string strMB = textArr[2];//模板代码 //参数信息格式化:{参数:'参数值',参数:'参数值'......} string[] strcs = strCSARR.Split(new char[] { '-' }); string scs = "{"; for (int i = 0; i < strcs.Length; i++) { if (i % 2 == 0) { scs = scs + strcs[i] + ":"; } else { scs = scs + "'" + strcs[i] + "',"; } } scs = scs.Substring(0, scs.Length - 1)+"}"; ITopClient client = new DefaultTopClient(AlidayuUrl, config.AppKey, config.AppSecret); AlibabaAliqinFcSmsNumSendRequest req = new AlibabaAliqinFcSmsNumSendRequest(); req.Extend = "";//好像没用,暂时舍弃 req.SmsType = "normal"; req.SmsFreeSignName = strQM; req.SmsParam = scs; req.RecNum = destination; req.SmsTemplateCode = strMB; Log.Info(client == null); try { AlibabaAliqinFcSmsNumSendResponse rsp = client.Execute(req); //Console.WriteLine(rsp.Body); if (rsp.Result.Success) { return "发送成功"; } else { return rsp.Result.Msg; } } catch (Exception ex) { Log.Error(ex, ex); return ex.Message; } /**/ } return "发送目标不能为空!"; }
0 0
- NET 阿里大于短信推送
- 阿里大于短信接口
- 阿里大于短信使用
- 阿里大于短信发送服务
- 阿里大于短信接口thinkphp
- 短信接口 阿里大于事例
- PB9阿里大于发短信
- 使用阿里大于发送短信
- 短信接口(阿里大于)
- 阿里大于短信平台使用
- asp.net mvc短信接口调用——阿里大于API开发心得
- tp使用阿里大于的短信接口
- 使用阿里大于发送短信验证码
- thinkphp引入 阿里大于短信平台
- 阿里大于短信平台 Python3 初体验
- 教你使用阿里大于发短信
- 利用阿里大于开发短信验证码
- 阿里大于手机注册短信验证码
- gcd lcm (最大公约数 最小公倍数)
- [转]Deep Learning(深度学…
- Sending SMS WAP Push messages using the ActiveXperts SMS and MMS Toolkit.
- (转)VirtualBox安装Mac OS 10.11——虚拟机安装黑苹果
- 神经网络来进行时间序列预测
- NET 阿里大于短信推送
- 正确遍历删除List中的元素(着重看iterator方式)
- Topic Model
- Win 10安装Cisco System VPN Client报错27850 Bug解决
- N-Gram学习笔记
- 文本分类的数据预处理相关知识介绍
- C# post 提交 application/json 类型数据
- 十三种常用的数据挖掘的技术&…
- 18-每天一个Linux命令 locate