public static void SendSms(string to, string message) { var twilio = new TwilioRestClient(TwilioAccountSid, TwilioAuthToken); twilio.SendMessage(FromNumber, to, message); }
public static void SendSmsToAllInvolved(int orderId, string action) { IstokDoorsDBContext db = new IstokDoorsDBContext(); var employeesToInform = db.Employees.Where(i => i.IsSmsInformed == true).ToList(); string messageText; if (action == "ship") { messageText = " Заказ " + orderId + " oтправлен! Проверьте Журнал Учёта Складских Запасов для дополнительной информации."; } else { messageText = " Заказ " + orderId + " oтменён! Проверьте Журнал Учёта Складских Запасов для дополнительной информации."; } var twilio = new TwilioRestClient(TwilioSender.AccountSid, TwilioSender.AuthToken); if (employeesToInform != null) { foreach (var employee in employeesToInform) { var message = twilio.SendMessage(TwilioSender.PhoneNumber, employee.PhoneNumber1, messageText, ""); } } }
private void OnTimer(object sender, ElapsedEventArgs e) { try { EventLog.WriteEntry("Checking for new bark", EventLogEntryType.Information); var newLatestBark = GetLatestBark().GetAwaiter().GetResult(); if (newLatestBark != null && (LatestBark == null || newLatestBark.Id != LatestBark.Id)) { EventLog.WriteEntry("Sending new bark: " + newLatestBark.Bark, EventLogEntryType.Information); if (!string.IsNullOrWhiteSpace(TwilioAccountSid) && !string.IsNullOrWhiteSpace(TwilioAuthToken)) { var twilioClient = new TwilioRestClient(TwilioAccountSid, TwilioAuthToken); twilioClient.SendMessage(TwilioSenderNumber, TwilioRecipentNumber, "🐶 " + newLatestBark.Bark); } else { EventLog.WriteEntry("Twilio account SID or AuthToken not configured", EventLogEntryType.Warning); } LatestBark = newLatestBark; } } catch (Exception exception) { EventLog.WriteEntry(exception.Message, EventLogEntryType.Error); } }
protected void Page_Load(object sender, EventArgs e) { string fromNumber = Request["From"]; string toNumber = Request["To"]; string smsBody = Request["Body"]; //check for invalid requests if (string.IsNullOrEmpty(smsBody)) return; var twilio = new TwilioRestClient(TWILIO_ACCOUNT_ID, TWILIO_AUTH_TOKEY); //Parse the message body, get the language SmsMessage smsMsg = new SmsMessage(smsBody); //Get the Google translation controller GoogleTranslateController translateController = new GoogleTranslateController(); //Get the language of the sms. string smsLanguageCode = translateController.DetectLanguage(smsMsg.Content); //Get the target language code. string targetLanguageCode = translateController.GetLanguageCode(smsMsg.Language, smsLanguageCode); //Get the translated message string translatedMessage = translateController.TranslateText(smsMsg.Content, targetLanguageCode); translatedMessage = HttpUtility.HtmlDecode(translatedMessage); var message = twilio.SendMessage(toNumber, fromNumber, translatedMessage, ""); }
public static Twilio.Message SendSms(string number, string content) { var formattedNumber = FormatPhoneNumber(number); var restClient = new TwilioRestClient(_config.GetString(ACCOUNT_SID_KEY), _config.GetString(AUTH_TOKEN_KEY)); return restClient.SendMessage(_config.GetString(PHONE_NUMBER_KEY), formattedNumber, content); }
public bool SendSMS(string number, string message) { var settings = _accountSettings.GetVoiceSettings(); var client = new TwilioRestClient(settings.AccountSid, settings.AuthToken); if (number.IndexOf('+') < 0) { number = "+" + number.Trim(); } var smsNumber = WebConfigurationManager.AppSettings["TwilioNumber"]; var result = client.SendMessage(smsNumber, number, message); if (result.RestException != null) { _logger.Error($"Exception thrown sending SMS to {number}. Ex - {result.RestException.Message}"); } if (result.Status != "queued") { _logger.Error($"SMS sent status - {result.Status}, {result.ErrorMessage}"); } _logger.Debug($"Sending SMS to {number} with content {message}"); return result.Status == "queued"; }
public string Get([FromUri] string phoneNumber, string flatteristId, string flattery) { const string accountSid = "YOURSIDE"; const string authToken = "YOURTOKEN"; const string fromNumber = "YOURNUMBER"; var client = new TwilioRestClient(accountSid, authToken); if (string.IsNullOrEmpty(flattery)) { var call = client.InitiateOutboundCall( fromNumber, // The number of the phone initiating the call string.Format("+{0}", phoneNumber), // The number of the phone receiving call string.Format("http://www.flatterist.com/{0}.mp3", flatteristId) // The URL Twilio will request when the call is answered ); if (call.RestException == null) { return string.Format("Started call: {0}", call.Sid); } return string.Format("Error: {0}", call.RestException.Message); } client.SendMessage(fromNumber, phoneNumber, flattery); return string.Format("Sent message to {0}", phoneNumber); }
private void SendSmsMessage(string username, MessageObject messageObj) { const string senderNumber = "+17245658130"; var twilioRestClient = new TwilioRestClient("AC47c7253af8c6fae4066c7fe3dbe4433c", "[AuthToken]"); var recipientNumber = Utils.GetNum(username); twilioRestClient.SendMessage(senderNumber, recipientNumber, messageObj.ShortMessage, MessageCallback); }
public void Main(string[] args) { var factory = new ConnectionFactory() { HostName = "localhost" }; var client = new TwilioRestClient(Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID"), Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN")); using (var connection = factory.CreateConnection()) { using (var channel = connection.CreateModel()) { channel.QueueDeclare("messages", false, false, false, null); var consumer = new QueueingBasicConsumer(channel); channel.BasicConsume("messages", true, consumer); Console.WriteLine(" [*] Waiting for messages." + "To exit press CTRL+C"); while (true) { var ea = (BasicDeliverEventArgs)consumer.Queue.Dequeue(); var message = JsonConvert.DeserializeObject<Libs.Message>(Encoding.UTF8.GetString(ea.Body)); Console.WriteLine(" [x] Received {0}", message.Body); // Send a nice message back to each one of the Inbound Messages client.SendMessage("", message.From, "Thanks for seeing me @ dmconf15. Here's some Twilio <3 to get you started, just use the code NOSQL15. Hit me up @marcos_placona"); } } } }
public string SendSMS(TxtMsgOutbound txtMsgOutbound) { if (!AppConfigSvcValues.Instance.SmsSimulationMode && OnWhiteList(txtMsgOutbound.MobilePhone)) { ThrottleCount++; if (ThrottleCount >= ThrottleMax) { _log.Warning("MaxThrottle count exceeded: " + ThrottleMax); } else { string msg = string.Format("Sending SMS to {0}. message: '{1}'. ThrottleCount:{2}", txtMsgOutbound.MobilePhone, txtMsgOutbound.Message, ThrottleCount); _log.Info(msg); var twilio = new TwilioRestClient(AppConfigSvcValues.Instance.TwilioAccountSid, AppConfigSvcValues.Instance.TwilioAuthToken); Message ret = twilio.SendMessage(AppConfigSvcValues.Instance.SourcePhone, txtMsgOutbound.MobilePhone, txtMsgOutbound.Message); //FutureDev: Send async _log.Info("Sent SMS, status: " + ret.Status); if (ret.Status != "queued") _log.Info("Error. Send to Twilio not successful. Status:" + ret.Status + " destPhone:" + txtMsgOutbound.MobilePhone); } } else { string reason = AppConfigSvcValues.Instance.SmsSimulationMode ? "Simulation" : "not on whitelist"; txtMsgOutbound.NotSendReason = reason; _log.Info("NOT Sending SMS to " + txtMsgOutbound.MobilePhone + " at " + txtMsgOutbound.MobilePhone + ". message: '" + txtMsgOutbound.Message + "' because " + reason); } _txtMsgOutboundDal.UpdateState(txtMsgOutbound, TxtMsgProcessState.Processed); return txtMsgOutbound.Id; }
public Task SendAsync(IdentityMessage message) { // Twilio Begin var Twilio = new TwilioRestClient( System.Configuration.ConfigurationManager.AppSettings["SMSAccountIdentification"], System.Configuration.ConfigurationManager.AppSettings["SMSAccountPassword"]); var result = Twilio.SendMessage( System.Configuration.ConfigurationManager.AppSettings["SMSAccountFrom"], message.Destination, message.Body ); //Status is one of Queued, Sending, Sent, Failed or null if the number is not valid Trace.TraceInformation(result.Status); //Twilio doesn't currently have an async API, so return success. return Task.FromResult(0); // Twilio End // ASPSMS Begin // var soapSms = new MvcPWx.ASPSMSX2.ASPSMSX2SoapClient("ASPSMSX2Soap"); // soapSms.SendSimpleTextSMS( // System.Configuration.ConfigurationManager.AppSettings["SMSAccountIdentification"], // System.Configuration.ConfigurationManager.AppSettings["SMSAccountPassword"], // message.Destination, // System.Configuration.ConfigurationManager.AppSettings["SMSAccountFrom"], // message.Body); // soapSms.Close(); // return Task.FromResult(0); // ASPSMS End }
public void SendMessage(string message, string imageUrl) { var twilioNumber = ConfigurationManager.AppSettings["TwilioPhoneNumber"]; var client = new TwilioRestClient( ConfigurationManager.AppSettings["TwilioAccountSid"], ConfigurationManager.AppSettings["TwilioAuthToken"] ); if(imageUrl != "") { client.SendMessage(twilioNumber, this.PhoneNumber, message, new string[] { imageUrl }); } else { client.SendMessage(twilioNumber, this.PhoneNumber, message); } }
//SendText method public static void SendText(string number, string body) { string AccountSid = ConfigurationManager.AppSettings["acctSid"]; string AuthToken = ConfigurationManager.AppSettings["authToken"]; var twilio = new TwilioRestClient(AccountSid, AuthToken); var message = twilio.SendMessage(ConfigurationManager.AppSettings["twilioNumber"], number, body); }
public void SendHospital() { string AccountSid = "ACb2f1376756059a1e5519b0d067b82148"; //test code: "AC6c6ee3afd79c247db7007242708362bc"; string AuthToken = "0d08e8a2856d360e9cd0816e19baa15f";//test token :"d32142ce915c5377daa34e7efd06183b"; var twilio = new TwilioRestClient(AccountSid, AuthToken); var message = twilio.SendMessage("+14803606485 ", "+6596372198", "Dear Mr Tan, Mr Lee (no:98623241) is sending your son to hospital by taxi as he is too drunk with bad health.\n --By HangOver", ""); }
public static void SendSms(string msg, string toNumber, string fromNumber) { var accountSid = ConfigurationManager.AppSettings["TwilioAccountSid"]; var authToken = ConfigurationManager.AppSettings["TwilioAuthToken"]; var twilio = new TwilioRestClient(accountSid, authToken); var sentMessage = twilio.SendMessage(fromNumber, toNumber, msg); }
private void SendSms() { string AccountSid = "ACaabca65ff12e9985848838bb2254064b"; string AuthToken = "{{ 181971c24690538268c1f10f90e37fc4 }}"; var twilio = new TwilioRestClient(AccountSid, AuthToken); var message = twilio.SendMessage("+61470051314", "+", "Jenny knows this <3", new string[] { "http://www.example.com/hearts.png" }); //Console.WriteLine(message.Sid); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string accountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string authToken = "your_auth_token"; var client = new TwilioRestClient(accountSid, authToken); var message = client.SendMessage("+15005550006", "+15005550009", "Hey Mr Nugget, you the bomb!"); Console.WriteLine(message.Sid); }
//method to send sms using Twilio public static void SendSMS(string msg) { var twilio = new TwilioRestClient(accountSid, authToken); var message = twilio.SendMessage( from: twilioPhoneNumber, to: smsRecipient, body: msg); }
public Task SendAsync(IdentityMessage message) { var Twilio = new Twilio.TwilioRestClient(ConfigurationManager.AppSettings["SMSSid"], ConfigurationManager.AppSettings["SMSToken"]); var result = Twilio.SendMessage(ConfigurationManager.AppSettings["SMSFromPhone"], message.Destination, message.Body, ""); // Plug in your SMS service here to send a text message. return(Task.FromResult(0)); }
public JsonResult SendAcceptance(string to, string name, string time) { var accountSid = Environment.GetEnvironmentVariable("Twilio_AccountSid"); var authToken = Environment.GetEnvironmentVariable("Twilio_AuthToken"); var twilio = new TwilioRestClient(accountSid, authToken); var message = twilio.SendMessage("441793250159", to, "Hello " + name + " Help is on the way, Don't Panic!, help will be with you in approximately " + time + "minutes"); return Json(message.Sid, JsonRequestBehavior.AllowGet); }
public ActionResult SendMessage(MessageToSend msg) { var twilio = new TwilioRestClient(AccountSid, AuthToken); var messageModel = twilio.SendMessage(destinatario,msg.to,msg.body); ViewBag.temp = messageModel; return View("Index"); }
public void SendSms(string message, string recipient) { var twilio = new TwilioRestClient(_twilioAccountSid, _twilioAuthToken); var m = twilio.SendMessage(_senderPhoneNumber, recipient, message, string.Empty); if (m.RestException != null) { throw new SendSmsException(m.RestException.Message); } }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; var twilio = new TwilioRestClient(AccountSid, AuthToken); var message = twilio.SendMessage("+14158141829", "+15558675309", "Jenny please?! I love you <3", new string[] {"http://www.example.com/hearts.png"}); Console.WriteLine(message.Sid); }
/// <summary> /// Sends an email /// </summary> /// <param name="emailAccount">Email account to use</param> /// <param name="subject">Subject</param> /// <param name="body">Body</param> /// <param name="fromAddress">From address</param> /// <param name="fromName">From display name</param> /// <param name="toAddress">To address</param> /// <param name="toName">To display name</param> /// <param name="replyTo">ReplyTo address</param> /// <param name="replyToName">ReplyTo display name</param> /// <param name="bcc">BCC addresses list</param> /// <param name="cc">CC addresses list</param> /// <param name="attachmentFilePath">Attachment file path</param> /// <param name="attachmentFileName">Attachment file name. If specified, then this file name will be sent to a recipient. Otherwise, "AttachmentFilePath" name will be used.</param> public void SendSms(string subject, string body, string fromNumber, string fromName, string toNumber, string toName, string replyToNumber = null, string replyToName = null, IEnumerable<string> bcc = null, IEnumerable<string> cc = null, string attachmentFilePath = null, string attachmentFileName = null) { var client = new TwilioRestClient(Properties.Settings.Default.Nop_Plugin_SMS_Twillio_Account_Sid, Properties.Settings.Default.Nop_Plugin_SMS_Twillio_Auth_Token); client.SendMessage(fromNumber, toNumber, body); }
public Task SendAsync(IdentityMessage message) { var Twilio = new TwilioRestClient(Keys.TwilioSid, Keys.TwilioToken); var result = Twilio.SendMessage(Keys.FromPhone, message.Destination, message.Body); // Status is one of Queued, Sending, Sent, Failed or null if the number is not valid new ExceptionLogger().LogTrace(result.Status); // Twilio doesn't currently have an async API, so return success. return Task.FromResult(0); }
public static async Task SendSms(string number, string message) { string AccountSid = "AC31ae3bf014300c048db3e592b8a15651"; string AuthToken = "e4cd7422e0e7b9d0837377781180d95e"; string twilioPhoneNumber = "+12515453790"; var twilio = new TwilioRestClient(AccountSid, AuthToken); twilio.SendMessage(twilioPhoneNumber, number, message); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; var twilio = new TwilioRestClient(AccountSid, AuthToken); var message = twilio.SendMessage("+15005550006", "+14108675309", "All in the game, yo"); Console.WriteLine(message.Sid); }
public Task SendAsync(IdentityMessage message) { const string accountSid = "AC3b29af3c1386d863bc858c2d5d49380b"; const string authToken = "48c0c0a7c3bb750ca365bf7e331ab074"; const string phoneNumber = "770-999-9875"; var twilioRestClient = new TwilioRestClient(accountSid, authToken); twilioRestClient.SendMessage(phoneNumber, message.Destination, message.Body); return Task.FromResult(0); }
public static void Main(string[] args) { string AccountSID = "ACea7d95460837ce02f507680274e46dd4"; string AuthToken = "{{ c7aa2968ee33a58e78d352610f014452 }}"; var twilio = new TwilioRestClient (AccountSID, AuthToken); var message = twilio.SendMessage ("+13213207529", "+14439457390", "Ayyyyyyyy lmaooooooo", ""); if (message.Sid != null) { Console.WriteLine (message.Body); } }
public static void SendMessages(IEnumerable<MaintTask> tasks) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACa934fe8648ea1d66ea735d8124d80747"; string AuthToken = "b9addbbf41f78e9fdcebc951ef764e5a"; var twilio = new TwilioRestClient(AccountSid, AuthToken); foreach (var task in tasks) { var message = twilio.SendMessage("+16159885814", "+16152903050", "TEST", ""); } }
public Task SendAsync(IdentityMessage message) { var twilio = new TwilioRestClient(_sid,_token); var result = twilio.SendMessage(_from, message.Destination, message.Body); // Status is one of Queued, Sending, Sent, Failed or null if the number is not valid Trace.TraceInformation(result.Status); // Twilio doesn't currently have an async API, so return success. return Task.FromResult(0); }
/// <summary> /// Send the secret /// </summary> public void Send(SecurityUser user, string challengeResponse, string tfaSecret) { if (user == null) { throw new ArgumentNullException(nameof(user)); } else if (String.IsNullOrEmpty(challengeResponse)) { throw new ArgumentNullException(nameof(challengeResponse)); } else if (tfaSecret == null) { throw new ArgumentNullException(nameof(tfaSecret)); } // First, does this user have a phone number string toNumber = user.PhoneNumber; if (toNumber == null) { // Get preferred language for the user var securityService = ApplicationServiceContext.Current.GetService <IRepositoryService <UserEntity> >(); var userEntity = securityService?.Find(o => o.SecurityUserKey == user.Key).FirstOrDefault(); if (userEntity != null) { toNumber = userEntity.Telecoms.FirstOrDefault(o => o.AddressUseKey == TelecomAddressUseKeys.MobileContact)?.Value; } } // To numbers fail if (toNumber == null || challengeResponse.Length != 4 || !toNumber.EndsWith(challengeResponse)) { this.m_tracer.TraceEvent(EventLevel.Warning, "Validation of {0} failed", user.UserName); } else { try { var client = new TW.TwilioRestClient(this.m_configuration.Sid, this.m_configuration.Auth); var response = client.SendMessage(this.m_configuration.From, toNumber, String.Format(Strings.default_body, tfaSecret)); if (response.RestException != null) { throw new Exception(response.RestException.Message ?? "" + " " + (response.RestException.Code ?? "") + " " + (response.RestException.MoreInfo ?? "") + " " + (response.RestException.Status ?? "")); } } catch (Exception ex) { this.m_tracer.TraceEvent(EventLevel.Error, "Error sending SMS: {0}", ex); } } }
/// <summary> /// Send the secret /// </summary> public String Send(SecurityUser user) { if (user == null) { throw new ArgumentNullException(nameof(user)); } // First, does this user have a phone number string toNumber = user.PhoneNumber; if (toNumber == null) { // Get preferred language for the user var securityService = ApplicationServiceContext.Current.GetService <IRepositoryService <UserEntity> >(); var userEntity = securityService?.Find(o => o.SecurityUserKey == user.Key).FirstOrDefault(); if (userEntity != null) { toNumber = userEntity.Telecoms.FirstOrDefault(o => o.AddressUseKey == TelecomAddressUseKeys.MobileContact)?.Value; } } try { // Generate a TFA secret and add it as a claim on the user var secret = ApplicationServiceContext.Current.GetService <ITwoFactorSecretGenerator>().GenerateTfaSecret(); ApplicationServiceContext.Current.GetService <IIdentityProviderService>().AddClaim(user.UserName, new SanteDBClaim(SanteDBClaimTypes.SanteDBOTAuthCode, secret), AuthenticationContext.SystemPrincipal, new TimeSpan(0, 5, 0)); var client = new TW.TwilioRestClient(this.m_configuration.Sid, this.m_configuration.Auth); var response = client.SendMessage(this.m_configuration.From, toNumber, String.Format(Strings.default_body, secret)); if (response.RestException != null) { throw new Exception(response.RestException.Message ?? "" + " " + (response.RestException.Code ?? "") + " " + (response.RestException.MoreInfo ?? "") + " " + (response.RestException.Status ?? "")); } return($"Code sent to ******{user.PhoneNumber.Substring(user.PhoneNumber.Length - 4, 4)}"); } catch (Exception ex) { this.m_tracer.TraceEvent(EventLevel.Error, "Error sending SMS: {0}", ex); throw new Exception($"Could not dispatch SMS code to user", ex); } }