public ActionResult <string> Post(SMSSend package) { var client = new RestClient("https://api.46elks.com/a1/SMS"); var request = new RestRequest(Method.POST); client.Authenticator = new RestSharp.Authenticators. HttpBasicAuthenticator(_config["Credentials:Elk:Username"], _config["Credentials:Elk:Password"]); request.AddParameter( "to", package.to, ParameterType.GetOrPost); request.AddParameter( "from", package.from, ParameterType.GetOrPost); request.AddParameter( "message", package.message, ParameterType.GetOrPost); IRestResponse response = client.Execute(request); return(response.Content); }
/// <summary> /// 推送短信 /// </summary> /// <param name="Phone">发送人手机号(可以多个用“,”分隔)</param> /// <param name="Content">模板参数(可以多个用“,”分隔。上限四个)</param> /// <param name="type">模板类型</param> /// <returns></returns> public string Send(string Phone, string Content, string type) { //MsgAPI.Service1SoapClient ws = new MsgAPI.Service1SoapClient(); //return ws.SendMessages("lifengyue", "lifengyue", Phone, Content, ""); string[] ContentStringArray = Content.Split(','); SMSSend SMS = new SMSSend(); string ContentString = string.Empty; switch (ContentStringArray.Length) { case 1: ContentString = string.Format(this.GetTemplates(type), ContentStringArray[0]); break; case 2: ContentString = string.Format(this.GetTemplates(type), ContentStringArray[0], ContentStringArray[1]); break; case 3: ContentString = string.Format(this.GetTemplates(type), ContentStringArray[0], ContentStringArray[1], ContentStringArray[2]); break; case 4: ContentString = string.Format(this.GetTemplates(type), ContentStringArray[0], ContentStringArray[1], ContentStringArray[2], ContentStringArray[3]); break; default: break; } return(SMS.ZhongZhengSMS(smsNo, smsPwd, Phone, ContentString, "")); }
public SMSSend ActionSend(string[] to, string text = null) { SMSSend action = new SMSSend(); action.Client(client); action.Proxy(proxy); action.SetTo(to); action.SetText(text); return(action); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.Run(async(context) => { }); SMSSend.SMSSendMsg(); }
public static async void SendSms(string number, string Message, String port) { SMSSend sms = new SMSSend(number, Message, port); await sms.SendAsync(); }