Yuebon.NetCore/Yuebon.SMS.Core/AliYun/AliYunSMS.cs

(开头部分) 6KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.Core.Http;
using Aliyun.Acs.Core.Profile;
using Newtonsoft.Json;
using System;
using Yuebon.Commons.Cache;
using Yuebon.Commons.Encrypt;
using Yuebon.Commons.Json;
using Yuebon.Commons.Log;
using Yuebon.Commons.Options;

namespace Yuebon.SMS.AliYun
{
    /// <summary>
    /// 阿里云短信接口
    /// </summary>
    public class AliYunSMS
    {
        //产品名称:云通信短信API产品
        private const string product = "Dysmsapi";
        //短信API产品域名
        private const string domain = "dysmsapi.aliyuncs.com";

        public AliYunSMS()
        {
            YuebonCacheHelper yuebonCacheHelper = new YuebonCacheHelper();
            AppSetting sysSetting = yuebonCacheHelper.Get<AppSetting>("SysSetting");
            if (sysSetting != null)
            {
                this.Appkey = DEncrypt.Decrypt(sysSetting.Smsusername);
                this.Appsecret = DEncrypt.Decrypt(sysSetting.Smspassword);
                this.SignName = sysSetting.SmsSignName;
            }
        }


        /// <summary>
        /// 群发
        /// </summary>
        /// <param name="phoneNumbers">必填:待发送手机号。支持JSON格式的批量调用,批量上限为100个手机号码</param>
        /// <param name="TemplateCode">必填:短信模板</param>
        /// <param name="message">必填:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为 "{\"name\":\"Tom\", \"code\":\"123\"}"</param>
        /// <param name="returnMsg"></param>
        /// <param name="OutId">可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者</param>
        /// <param name="speed"></param>
        /// <returns></returns>
        public bool Send(string[] phoneNumbers, string TemplateCode, string message, out string returnMsg, string OutId = "", string speed = "1")
        {
            if ((((phoneNumbers == null) || (phoneNumbers.Length == 0)) || string.IsNullOrEmpty(message)) || (message.Trim().Length == 0))
            {
                returnMsg = "手机号码和消息内容不能为空";
                return false;
            }
            string phoneNumbersTot = string.Join(",", phoneNumbers);

            return this.Send(phoneNumbersTot, TemplateCode, message, out returnMsg, OutId, "0");

        }

后面还有 97 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。