Beispiel #1
0
        public void SendSMS(string mobilenumber, string SMSmessage)
        {
            /*
             * // Only to send e-mails...
             * MailAddress mail = new MailAddress("[email protected] <[email protected]>"); //Reciever, you need
             * MailMessage message = new MailMessage();                                                                                                     //need to add the WHOLE address
             * message.To.Add(mail);                                                                                                                        //including the number
             *
             * message.From = new MailAddress("*****@*****.**"); //Sender
             * message.Subject = "";
             * message.Body = SMSmessage;
             *
             * //logging into email
             * SmtpClient smtpclient = new SmtpClient("smtp.gmail.com", 587);  //setting up the smtp client
             * smtpclient.Credentials = new NetworkCredential("*****@*****.**", "aneoeled1");
             * smtpclient.EnableSsl = true;
             *
             *
             * smtpclient.Send(message);  //sending SMS.
             *
             */

            // Find your Account Sid and Auth Token at twilio.com / user / account


            string AccountSid = "ACf0c643e76cdad4e4533c9e06ef564072";
            string AuthToken  = "41b4b6289a04e489cd1d149303dddca7";
            var    twilio     = new Twilio.TwilioRestClient(AccountSid, AuthToken);

            var smsmessage = twilio.SendMessage("+441603914009", mobilenumber, SMSmessage);

            Console.WriteLine(smsmessage.Sid);
        }
Beispiel #2
0
        public async Task <IHttpActionResult> SendSms(Message message)
        {
            //// select the top 1 phone number by churchId order by preferred desc

            //// See this link for Twilio getting started:
            //https://www.twilio.com/docs/quickstart/csharp/sms/sending-via-rest

            var id = this.repo.SaveMessage(message);

            message.Id = id;

            var config = this.repo.GetSmsConfiguration(message.RecipientGroupId);

            //// these are test credentials.  These need to be stored in the database, because it will be different for each church.
            //var accountSID = "ACbf84ef7f4c8900348b5fbbd4f7c519f2";
            //var authToken = "481094fec8f4f91654afcb7c03b5e259";
            ////sender = "+15005550006"; this is Gary's twilio phone number for sending sms.

            //config.Sid = "AC743a79079b3df525e74b71ba2498ba7b"; //= "PN95fb71e231746fad3c988398976f2a42";  // sid for Gary's number:  "+12536552307
            //config.Token = "a14f98f62a64d3e00d9a2472f7caf895";
            //config.PhoneNumber = "+12536552307";  // Gary's number that he bought - $1 a month - for dev only, canncel ASAP

            var client = new Twilio.TwilioRestClient(config.Sid, config.Token);

            var recipients = this.repo.GetGroupRecipients(message.RecipientGroupId, 47);

            foreach (var recipient in recipients)
            {
                await Task.Run(() => {
                    var sms = client.SendMessage(config.PhoneNumber, recipient.Address, message.Body);
                });
            }

            return(Ok(message));
        }
Beispiel #3
0
        public bool SMStsatus(string to, string from, string message)
        {
            string AccountSid = "AC38ace510c0bab7f8f9aa436e420a9c29";
            string AuthToken  = "80237d8a546b3b17b30b1c424d515491";
            var    twilio     = new Twilio.TwilioRestClient(AccountSid, AuthToken);


            //    var mess = twilio.SendMessage(
            //    "+13477565536", "+917797073789",
            //    "Hi Ishita..."
            //);
            var mess = twilio.SendMessage(
                from, to,
                message
                );

            if (mess != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #4
0
        public ActionResult PageViaSMS(string phone)
        {
            string message = "An event has occurred";
            var    twilio  = new Twilio.TwilioRestClient(Settings.TwilioAccount, Settings.TwilioToken);
            var    sms     = twilio.SendMessage(Settings.TwilioPhoneNumber, phone, message);

            ViewBag.Message = "Message " + sms.Status;
            return(View("Index"));
        }
Beispiel #5
0
        // This function will get triggered/executed when a new message is written
        // on an Azure Queue called queue.
        public static void ProcessQueueMessage([QueueTrigger("reminderqueue")] string message, TextWriter log)
        {
            Twilio.TwilioRestClient twil = new Twilio.TwilioRestClient(ConfigurationManager.AppSettings["TwilioAccountSid"],
                ConfigurationManager.AppSettings["TwilioAuthToken"]);
            string ourNumber = ConfigurationManager.AppSettings["TwilioPhoneNumber"];

            ToSend to = JsonConvert.DeserializeObject<ToSend>(message);

            twil.SendSmsMessage(ourNumber, to.To, to.Message);
        }
Beispiel #6
0
        public Task SendAsync(IdentityMessage message)
        {
            string accountSid        = ConfigurationManager.AppSettings["twilioAccountSid"];
            string authToken         = ConfigurationManager.AppSettings["twilioAuthToken"];
            string twilioPhoneNumber = ConfigurationManager.AppSettings["twilioPhoneNumber"];
            var    twilio            = new Twilio.TwilioRestClient(accountSid, authToken);

            twilio.SendMessage(twilioPhoneNumber, message.Destination, message.Body);
            return(Task.FromResult(0));
        }
Beispiel #7
0
        public Task SendSmsAsync(string number, string message)
        {
            var twilio = new Twilio.TwilioRestClient(
                Options.SID,           // Account Sid from dashboard
                Options.AuthToken);    // Auth Token

            var result = twilio.SendMessage(Options.SendNumber, number, message);
            // Use the debug output for testing without receiving a SMS message.
            // Remove the Debug.WriteLine(message) line after debugging.
            // System.Diagnostics.Debug.WriteLine(message);
            return Task.FromResult(0);
        }
        public void NotifySubscribedUsers(Activity activity)
        {
            var twilio = new Twilio.TwilioRestClient("ACba61716bbf4e431290e8d11868616813", "a0bea4676879689faba0c055e116c263");
            //var phoneNumber = twilio.GetIncomingPhoneNumber("PN807993f491b0c08be90ed6df0481b49d");
            var phoneNumber = twilio.GetIncomingPhoneNumber("PN0d57152a395c027dcb15a01c1263eb10");

            foreach (var userActivity in activity.UserActivities)
            {
                var phone   = userActivity.User.PhoneNumber;
                var message = twilio.SendMessage(phoneNumber.PhoneNumber, phone,
                                                 $"L'activité {activity.Title} aura bientôt lieu: {activity.Date}. Répondez OUI {activity.ShortCode} si vous acceptez d'être chauffeur.");
            }
        }
Beispiel #9
0
        public Task SendAsync(IdentityMessage message)
        {
            // TO DO: Plug in your SMS service here to send a text message.
            const string accountSid  = "ACb9a9dfdcb9f048ded69312aaa2071fc5";
            const string authToken   = "b355cbe45394ef65f374d26cb4ba7a5f";
            const string phoneNumber = "9083377541";

            var twilioRestClient = new Twilio.TwilioRestClient(accountSid, authToken);

            twilioRestClient.SendMessage(phoneNumber, message.Destination, message.Body);

            return(Task.FromResult(0));
        }
Beispiel #10
0
        public Task SendSmsAsync(string number, string message)
        {
            var twilio = new Twilio.TwilioRestClient(
                Options.SID,           // Account Sid from dashboard
                Options.AuthToken);    // Auth Token

            var result = twilio.SendMessage(Options.SendNumber, number, message);

            // Use the debug output for testing without receiving a SMS message.
            // Remove the Debug.WriteLine(message) line after debugging.
            // System.Diagnostics.Debug.WriteLine(message);
            return(Task.FromResult(0));
        }
        private string TwilioSendSMS(string telNumber)
        {
            string AccountSid = "ACaa7ce275ebee497a57578ca3b49d8ff6";
            string AuthToken  = "fedd9fe73a1019751227bb7052ccd4e0";
            string code       = codeGenerator();

            var client = new Twilio.TwilioRestClient(AccountSid, AuthToken);

            var message = client.SendMessage(
                "+14157952977", "+57" + telNumber,
                "Ganaste un Sandwich presenta el codigo " + code + " para reclamarlo"
                );

            return(code);
        }
        public void SendDriverConfirmation(Activity activity)
        {
            var twilio = new Twilio.TwilioRestClient("ACba61716bbf4e431290e8d11868616813", "a0bea4676879689faba0c055e116c263");
            //var phoneNumber = twilio.GetIncomingPhoneNumber("PN807993f491b0c08be90ed6df0481b49d");
            var phoneNumber = twilio.GetIncomingPhoneNumber("PN0d57152a395c027dcb15a01c1263eb10");

            var driverConfirmation = twilio.SendMessage(phoneNumber.PhoneNumber, activity.Driver.PhoneNumber,
                                                        $"Merci pilote ! Vous êtes prié de ne plus boire de bière 2h avant le départ.");

            foreach (var userActivity in activity.UserActivities)
            {
                var phone   = userActivity.User.PhoneNumber;
                var message = twilio.SendMessage(phoneNumber.PhoneNumber, phone,
                                                 $"L'activité {activity.Title} a trouvé son pilote. On remercie {activity.Driver.Firstname} {activity.Driver.Lastname}.");
            }
        }
        public Task SendSmsAsync(string number, string message)
        {
            var SID       = "AC02a0015664dc24eaa87a6858bbd83407";
            var AuthToken = "beb828b769d64666169a4e8c7ba4d0ca";
            var twilio    = new Twilio.TwilioRestClient(
                SID,           // Account Sid from dashboard
                AuthToken);    // Auth Token


            var result = twilio.SendMessage("+14782922479", "+14784644779", message);

            // Use the debug output for testing without receiving a SMS message.
            // Remove the Debug.WriteLine(message) line after debugging.
            // System.Diagnostics.Debug.WriteLine(result);
            return(Task.FromResult(0));
        }
        public void GeneratePass(string forName)
        {
            Random r = new Random();
            string password = "";
            for (int i = 0; i < 4; i++)
            {
                string name = Names.Keys.ElementAt(r.Next(Names.Count));

                password += name + " ";
            }
            password = password.Trim();
            TelephoneList[forName] = password;
            // SMS it
            var twilio = new Twilio.TwilioRestClient("ACa23f5b1a623ffbaa2958a7f91b985f03", "74bf07d264faa42d49bcc316e20e4895");
            var tMessage = twilio.SendMessage("+441502797245", Names[forName], password);
            LastPerson = forName;
        }
Beispiel #15
0
        public void GeneratePass(string forName)
        {
            Random r        = new Random();
            string password = "";

            for (int i = 0; i < 4; i++)
            {
                string name = Names.Keys.ElementAt(r.Next(Names.Count));

                password += name + " ";
            }
            password = password.Trim();
            TelephoneList[forName] = password;
            // SMS it
            var twilio   = new Twilio.TwilioRestClient("ACa23f5b1a623ffbaa2958a7f91b985f03", "74bf07d264faa42d49bcc316e20e4895");
            var tMessage = twilio.SendMessage("+441502797245", Names[forName], password);

            LastPerson = forName;
        }
        public Task SendAsync(IdentityMessage message)
        {
            // Plug in your SMS service here to send a text message.
            // Twilio Begin
            var Twilio = new Twilio.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.
            //SendSMS(message.Destination, message.Body);
            return(Task.FromResult(0));
            // Twilio End
        }
        public static NotificationResult SendSMS(PhoneNumber To, String Message)
        {
            NotificationResult result = new NotificationResult();
            var twilio = new Twilio.TwilioRestClient(Settings.TwilioAccount, Settings.TwilioToken);
            var sms    = twilio.SendMessage(Settings.TwilioPhoneNumber, To.ToInternationalDialString(), Message);

            if (sms.ErrorCode.HasValue)
            {
                result.Success      = false;
                result.MessageCount = 0;
                result.Detail       = sms.ErrorMessage;
            }
            else
            {
                result.Success      = true;
                result.MessageCount = 1;
                if (sms.Status != "queued")
                {
                    result.Detail = sms.Status;
                }
            }
            return(result);
        }
Beispiel #18
0
 public static void SendSms(string recipient, string message)
 {
     var twilio = new Twilio.TwilioRestClient(TwilioAccountSid, TwilioAuthToken);
     twilio.SendSmsMessage(TwilioFromNumber, CleanPhoneNumber(recipient), message, null, (msg) => { });            
 }
Beispiel #19
0
 public static void SendSms(string to, string message)
 {
     var twilio = new Twilio.TwilioRestClient(TwilioKey, TwilSecret);
     twilio.SendMessage(FromNumber, to, message);
 }
Beispiel #20
0
        public void SendSMSViaTwilio()
        {
            //https://www.twilio.com/user/account/messaging/getting-started
            //Twilio Number (609) 337-3359
            //AccountSid = "ACd0f0ed61154fb4422652200d1263f2b6";
            //string AuthToken = "a8b808126f393a7557edde721c35b708";
            //urls:
            //Voice URL: https://demo.twilio.com/welcome/voice/
            //Messaging URL:https://demo.twilio.com/welcome/sms/reply/
            //Base URL:A ll URLs referenced in the documentation have the following base:   https://api.twilio.com/2010-04-01


            //https://www.twilio.com/user/account/messaging/dev-tools/api-explorer/message-create
            //=========================================================================================
            // Download the twilio-csharp library from twilio.com/docs/csharp/install
            //using System;
            //using Twilio;
            //Example:


            // Find your Account Sid and Auth Token at twilio.com/user/account
            string AccountSid = "ACd0f0ed61154fb4422652200d1263f2b6";
            string AuthToken  = "a8b808126f393a7557edde721c35b708";
            var    twilio     = new Twilio.TwilioRestClient(AccountSid, AuthToken);

            //this works
            //var message = twilio.SendMessage("6093373359", "6092735136", "this is a message from cei", "");

            //this should send an image of a hamster eating a four-leaf clover:
            var message = twilio.SendMessage("6093373359", "6092735136xx", "this is a message from cei", new string[] { "http://farm2.static.flickr.com/1075/1404618563_3ed9a44a3a.jpg" }, "");

            if (message.Sid == null)
            {
                Console.WriteLine("GAAK! - something was wrong with the message, because the message Sid was {0}", message.Sid);
                throw new Exception("TWILIO BOMB");
            }
            else
            {
                Console.WriteLine("All Good! - the message SID was: " + message.Sid);
            }


            //{
            //              "sid": "SM280076cde11041a599bbcfa4b995d6e5",
            //"date_created": "Thu, 21 Apr 2016 17:18:46 +0000",
            //"date_updated": "Thu, 21 Apr 2016 17:18:46 +0000",
            //"date_sent": null,
            //"account_sid": "ACd0f0ed61154fb4422652200d1263f2b6",
            //"to": "+16092735136",
            //"from": "+16093373359",
            //"messaging_service_sid": null,
            //"body": "Sent from your Twilio trial account - this is a message from cei",
            //"status": "queued",
            //"num_segments": "1",
            //"num_media": "0",
            //"direction": "outbound-api",
            //"api_version": "2010-04-01",
            //"price": null,
            //"price_unit": "USD",
            //"error_code": null,
            //"error_message": null,
            //"uri": "/2010-04-01/Accounts/ACd0f0ed61154fb4422652200d1263f2b6/Messages/SM280076cde11041a599bbcfa4b995d6e5.json",
            //"subresource_uris": {
            //                  "media": "/2010-04-01/Accounts/ACd0f0ed61154fb4422652200d1263f2b6/Messages/SM280076cde11041a599bbcfa4b995d6e5/Media.json"
            //}
            //          }
        }
Beispiel #21
0
        public static void SendSms(string recipient, string message)
        {
            var twilio = new Twilio.TwilioRestClient(TwilioAccountSid, TwilioAuthToken);

            twilio.SendSmsMessage(TwilioFromNumber, CleanPhoneNumber(recipient), message, null, (msg) => { });
        }
        protected override void OnStart(string[] args)
        {
            sendGroups = new List <SendGroup>
            {
                new SendGroup
                {
                    field = "Pot30",
                    from  = 1,
                    to    = 29
                },
                new SendGroup
                {
                    field = "Pot60",
                    from  = 30,
                    to    = 59
                },
                new SendGroup
                {
                    field = "Pot90",
                    from  = 60,
                    to    = 89
                },
                new SendGroup
                {
                    field = "Pot120",
                    from  = 90,
                    to    = 119
                },
                new SendGroup
                {
                    field = "ChargeOff",
                    from  = 120,
                    to    = 99999
                },
            };

            try
            {
                var appSettings = ConfigurationManager.AppSettings;
                FromEmail        = appSettings["fromEmail"];
                FromName         = appSettings["fromName"];
                Frequency        = Int32.Parse(appSettings["frequency"].ToString());
                LimitPerGroup    = Int32.Parse(appSettings["limitPerGroup"].ToString());
                Subject          = appSettings["subject"];
                MandrilApiKey    = appSettings["mandrillApiKey"];
                DatabaseTable    = appSettings["databaseTable"];
                MandrillTemplate = "";// appSettings["mandrillTemplate"];

                twilioAccountSid              = appSettings["twilioAccountSid"];
                twilioAuthToken               = appSettings["twilioAuthToken"];
                twilioAccountResourceSid      = appSettings["twilioAccountResourceSid"];
                twilioApiVersion              = appSettings["twilioApiVersion"];
                twilioBaseUrl                 = appSettings["twilioBaseUrl"];
                twilioMessageFormat           = appSettings["twilioMessageFormat"];
                twilioSetFinancialPhoneNumber = appSettings["twilioSetFinancialPhoneNumber"];
            }

            catch (ConfigurationErrorsException e)
            {
            }

            mandrill = new MandrillApi(MandrilApiKey);
            twilio   = new Twilio.TwilioRestClient(twilioAccountSid, twilioAuthToken);

            // Set up a timer to trigger every minute.
            timer          = new System.Timers.Timer();
            timer.Interval = 60000 * Frequency; // 60 seconds
            timer.Elapsed += new System.Timers.ElapsedEventHandler(this.OnTimer);
            timer.Start();
            OnTimer(null, null);
        }
        protected void RPbtnSMSSendDept_Click(object sender, EventArgs e)
        {
            try
            {
                #region "Start"
                if (Page.IsValid)
                {
                    LRlblSmSResultDept.Visible = true;

                    string SMSLongCode = string.Empty, Mobile = string.Empty, Message = string.Empty, CampusID = string.Empty,
                           StudentNo = string.Empty, LeadNo = string.Empty, DeptId = string.Empty, isdcode = string.Empty;
                    lblSmSResultDept.Text = string.Empty;
                    CampusID = Convert.ToString(Session["CampusID"]);
                    DeptId   = Convert.ToString(Session["DeptID"]);

                    StudentNo = "0";
                    LeadNo    = "0";

                    SMSLongCode = Convert.ToString(RddlSMSLongCodeDept.SelectedText);
                    isdcode     = Convert.ToString(RtxtIscode.Text);
                    Mobile      = isdcode + Convert.ToString(RtxtMobileDept.Text);
                    Message     = Convert.ToString(REMessageSMSEditorDept.Text);
                    string SMSLongCodeId = string.Empty;
                    SMSLongCodeId = Convert.ToString(RddlSMSLongCodeDept.SelectedValue);
                    DataTable dtSMSSetup = DataAccessManager.GetSMSLongCodeFullList(Convert.ToString(Session["CampusID"]), SMSLongCodeId);
                    if (dtSMSSetup.Rows.Count > 0)
                    {
                        try
                        {
                            var twilio  = new Twilio.TwilioRestClient(dtSMSSetup.Rows[0]["AccountSID"].ToString(), dtSMSSetup.Rows[0]["AuthToken"].ToString());
                            var message = twilio.SendMessage(SMSLongCode, Mobile, Message);
                            if (message != null)
                            {
                                if (message.Sid != null)
                                {
                                    try
                                    {
                                        var     twilioGet = new Twilio.TwilioRestClient(dtSMSSetup.Rows[0]["AccountSID"].ToString(), dtSMSSetup.Rows[0]["AuthToken"].ToString());
                                        var     msg       = twilioGet.GetMessage(message.Sid);
                                        Boolean result    = DataAccessManager.ReadSMSAndSaveDatabase(msg.AccountSid, msg.DateSent.ToString("yyyy-MM-dd HH:mm:ss"), Convert.ToString(msg.Sid), Convert.ToString(msg.To), Convert.ToString(msg.From), Convert.ToString(msg.Body), Convert.ToString(msg.Status), Convert.ToString(msg.Direction), Convert.ToString(msg.ErrorCode), Convert.ToString(msg.ErrorMessage), msg.DateCreated.ToString("yyyy-MM-dd HH:mm:ss"), msg.DateUpdated.ToString("yyyy-MM-dd HH:mm:ss"), Convert.ToString(StudentNo), Convert.ToString(LeadNo), Convert.ToString(DeptId));
                                        if (result == true)
                                        {
                                            RPbtnSMSSendDept.Enabled = true;
                                            //lblSmSResultDept.Text = "Message has been sent!";
                                            if (Convert.ToInt32(ViewState["count"]) == 2)
                                            {
                                                RddlSMSLongCodeDept.SelectedIndex = 1;
                                            }

                                            RtxtMobileDept.Text         = string.Empty;
                                            REMessageSMSEditorDept.Text = string.Empty;
                                            RtxtIscode.Text             = "+1";

                                            /*27 july change After SMS Message send, return to SMS page*/
                                            /*Start*/
                                            string LeadId = string.Empty;
                                            LeadId    = Convert.ToString(Session["LeadId"]);
                                            StudentNo = Convert.ToString(Session["StudentNo"]);

                                            string type = string.Empty;
                                            if (StudentNo != string.Empty && StudentNo != null && StudentNo != "0")
                                            {
                                                type = "Student";
                                            }
                                            if (LeadId != string.Empty && LeadId != null && LeadId != "0")
                                            {
                                                type = "Lead";
                                            }

                                            Session["PageClick"] = "0";
                                            Response.Redirect("~/frmdepartment.aspx?type=Department&Operation=Receive SMS");
                                            /*End*/
                                        }
                                        // DeptGridBind("SMSSent");
                                        //  DeptGridBind("SMSReceived"); ;
                                    }
                                    catch (Exception ex)
                                    {
                                        RPbtnSMSSendDept.Enabled = true;
                                        lblSmSResultDept.Text    = "Message Failed!";
                                    }
                                }
                                else
                                {
                                    lblSmSResultDept.Text = "Message failed,Please check the number.";
                                }
                            }
                            else
                            {
                                lblSmSResultDept.Text = "Message Failed!";
                            }
                        }
                        catch (Exception ex)
                        {
                            RPbtnSMSSendDept.Enabled = true;
                            lblSmSResultDept.Text    = "Message Failed!";
                        }
                    }

                    else
                    {
                        lblSmSResultDept.Text = "Please make sure update SMS Configration!.";
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
            }
        }
Beispiel #24
0
 public static void Call(string to, string message)
 {
     var twilio = new Twilio.TwilioRestClient(TwilioKey, TwilSecret);
     var call = twilio.InitiateOutboundCall(FromNumber, to, message);
 }