public SMSMessage NewSMSRequest(SMSOptions options) { var v = new LogObj() { LogSymbol = LogSymbol.TwilioToPhone, Caption = "Sms Message" }.AddNode("Sms Message", options.body).LogIt(); SystemController.Instance.PhoneManager.SMSReceived(options.from, options.to, options.body); CallStatusWebClient cswb = new CallStatusWebClient(); if (options.statusCallback != null) { cswb.DoRequest(options.statusCallback, new NameValueCollection() { { "SmsStatus", "sent" }, { "SmsSid", CreateSid() } }); } return(new SMSMessage() { DateCreated = DateTime.Now, DateSent = DateTime.Now, Direction = "outbound-api", From = options.from, To = options.to, Status = "sent", Sid = Guid.NewGuid().ToString().Replace("-", "") }); }
protected TwimlVerbResult SMS(XElement twimnode) { string action = twimnode.Attributes("action").Any() ? twimnode.Attribute("timeout").Value : ""; SMSOptions s = new SMSOptions() { to = twimnode.Attribute("to").Value, from = twimnode.Attribute("from").Value, body = twimnode.Attribute("body").Value, statusCallback = twimnode.Attribute("statusCallback").Value }; SystemController.Instance.Office.NewSMSRequest(s); if (action != "") { TwimlPath = action; TwimlLogAs = "SMS Action URL "; return(TwimlVerbResult.Redirect); } else { return(TwimlVerbResult.Continue); } }
/// <summary> /// </summary> /// <param name="strokeContext">The stroke context.</param> /// <param name="logger"></param> /// <param name="options"></param> /// <param name="contextAccessor"></param> /// <param name="memory"></param> public SMSService(StrokeContext strokeContext, ILogger <SMSService> logger, IOptions <SMSOptions> options, IHttpContextAccessor contextAccessor, IMemoryCache memory) { this.strokeContext = strokeContext; this.Logger = logger; this.contextAccessor = contextAccessor; this.memory = memory; this.options = options.Value; }
public SMSMessage Messages(SMSOptions options) { var a = SystemController.Instance.Office.NewSMSRequest(options); var lg = new LogObj() { Caption = "SMS Request From Application ", LogSymbol = Code.LogSymbol.WebToTwilio, }; lg.AddNode("Request", options).AddNode("Response", a).LogIt(); return(a); }
/// <summary> /// Initializes a new instance of the <see cref="UserService"/> class. /// </summary> /// <param name="strokeContext">The stroke context.</param> /// <param name="weChatOptions">The we chat options.</param> /// <param name="logger"></param> /// <param name="jwtOptions"></param> /// <param name="contextAccessor"></param> /// <param name="smsOptions"></param> /// <param name="memory"></param> /// <param name="hostingEnvironment"></param> public UserService(StrokeContext strokeContext, IOptions <WeChatOptions> weChatOptions, ILogger <UserService> logger, IOptions <JwtOptions> jwtOptions, IHttpContextAccessor contextAccessor, IOptions <SMSOptions> smsOptions, IMemoryCache memory, IHostingEnvironment hostingEnvironment ) { this.strokeContext = strokeContext; this.weChatOptions = weChatOptions.Value; this.Logger = logger; this.jwtOptions = jwtOptions.Value; this.contextAccessor = contextAccessor; this.smsOptions = smsOptions.Value; this.memory = memory; this.hostingEnvironment = hostingEnvironment; }
public SmsService(IConfiguration configuration) { Configuration = configuration; Options = Configuration.GetSection("Authentication:SMS").Get <SMSOptions>(); }
private static string Sign(this SMSOptions option) { return Hash($"{option.CompanyCode}{option.Phone}{option.Timestamp}{option.MD5Key}"); }
/// <summary> /// 下发验证码方法 /// </summary> /// <param name="client"></param> /// <param name="option"></param> /// <returns></returns> public static async System.Threading.Tasks.Task<bool> SendCode(this HttpClient client, SMSOptions option) { option.Timestamp = (DateTimeOffset.UtcNow.Ticks - 621355968000000000) / 10000000; var requestParameters = new Dictionary<string, string>() { { "CompanyCode", option.CompanyCode }, { "Phone", option.Phone }, { "TimeStamp", option.Timestamp.ToString() }, { "Sign", option.Sign() } }; var url = QueryHelpers.AddQueryString("http://open.bluegoon.com/api/sms/sendcode", requestParameters); var req = await client.GetAsync(url); var content = await req.Content.ReadAsStringAsync(); #if NETCOREAPP3_0 var result = JsonSerializer.Deserialize<SMSResult>(content, new JsonSerializerOptions() { PropertyNameCaseInsensitive = true }); #else var result = JsonConvert.DeserializeObject<SMSResult>(content, new JsonSerializerSettings() { ContractResolver = new DefaultContractResolver() }); #endif var ret = false; if (result.Code == 1) { _pool.AddOrUpdate(option.Phone, key => new AutoExpireValidateCode(option.Phone, result.Data, option.Expires), (key, v) => v.Reset(result.Data)); ret = true; } else { new Exception("SMS Send Fail").Log(new NameValueCollection() { ["UserId"] = option.Phone, ["url"] = url, ["content"] = content }); } return ret; }
/// <summary> /// 构造函数 /// </summary> /// <param name="configuration"></param> /// <param name="factory"></param> public DefaultSMSProvider(IConfiguration configuration, IHttpClientFactory factory) { Option = configuration.GetSection <SMSOptions>().Get <SMSOptions>(); _client = factory.CreateClient(); }
public DefaultSMSProvider() { Options = new SMSOptions(); Options.Roles.Add("Administrators"); Options.Roles.Add("Default"); }
public SmsService(IOptions <SMSOptions> options) { _options = options.Value; }