/// <summary> /// envia a mensagem /// </summary> /// <returns>string retorno da api</returns> public virtual string Enviar() { string result = ""; if (string.IsNullOrWhiteSpace(this.TelefoneDestinatario)) { return("Telefone em branco"); } if (string.IsNullOrWhiteSpace(this.Corpo)) { return("Mensagem em branco"); } try { EndpointAddress endereco = new EndpointAddress(this.Servidor); BasicHttpBinding binding = new BasicHttpBinding(); ServiceSMSSoapClient srv = new ServiceSMSSoapClient(binding, endereco); List <Destination> list = new List <Destination>(); list.Add(new Destination() { Name = NomeDestinatario, Number = TelefoneDestinatario .Replace(" ", "") .Replace("-", "") .Replace("(", "") .Replace(")", "") }); rSMS sms = new rSMS(); sms.Destinations = list.ToArray(); sms.Flash = false; sms.Msg = Corpo; sms.Preso = false; sms.Subject = Assunto; sms.WarningBeginningTransmission = false; result = srv.SendSMS(Usuario, Senha, sms); } catch (Exception err) { result = err.ToString(); } return(result); }
/// <summary> /// envia a mensagem /// </summary> /// <returns>string retorno da api</returns> public virtual string Enviar() { string result = ""; if (string.IsNullOrWhiteSpace(this.TelefoneDestinatario)) { return("Telefone em branco"); } if (string.IsNullOrWhiteSpace(this.Corpo)) { return("Mensagem em branco"); } Protocol p = Protocol.Default; try { string numero = "55-" + TelefoneDestinatario .Replace(" ", "") .Replace("-", "") .Replace("(", "") .Replace(")", ""); EgoiApi api = EgoiApiFactory.getApi(p); EgoiMap arguments = new EgoiMap(); arguments.Add("apikey", ApiKey); arguments.Add("subject", Assunto); arguments.Add("cellphone", numero); arguments.Add("message", Corpo); arguments.Add("listID", this._listId); arguments.Add("fromID", this._fromId); EgoiMap resultadoEgoy = api.sendSMS(arguments); result += resultadoEgoy.ToString(); } catch (Exception err) { result = err.ToString(); } return(result); }
/// <summary> /// envia a mensagem /// </summary> /// <returns>string retorno da api</returns> public virtual string Enviar() { string result = ""; string telefone = "+55" + TelefoneDestinatario .Replace(" ", "") .Replace("-", "") .Replace("(", "") .Replace(")", ""); using (WebClient client = new WebClient()) { byte[] response = client.UploadValues(new Uri("http://textbelt.com/text"), new NameValueCollection() { { "phone", telefone }, { "message", Corpo }, { "key", ApiKey }, }); result = System.Text.Encoding.UTF8.GetString(response); } return(result); }