Exemple #1
0
		/// <summary>
		/// Send an SMS message
		/// </summary>
		/// <param name="from">The number to send the message from</param>
		/// <param name="to">The number to send the message to</param>
		/// <param name="body">The contents of the message, up to 160 characters</param>
		/// <param name="statusCallbackUrl">The URL to notify of the message status</param>
		/// <returns>An SMSMessage Instance resource</returns>
		public static SMSMessage SendSms(string from, string to, string body, string statusCallbackUrl)
		{
			CheckForCredentials();

			var twilio = new TwilioRestClient(AccountSid, AuthToken);
			return twilio.SendSmsMessage(from, to, body, statusCallbackUrl);	
		}
    protected void SendPassButton_Click(object sender, EventArgs e)
    {

        string MyNum = "16093850962";
        string AcctID = "ACfe8686a211342fd1e55bb6654995c77f";
        string AuthTok = "197a4597c18dff5f22208f12151e2d64";

        TwilioRestClient clnt = new TwilioRestClient(AcctID, AuthTok); 

       clnt.SendSmsMessage(MyNum, ForgotTextBox.Text, "Yo What up");

        SqlConnection cont = new SqlConnection(ConfigurationManager.ConnectionStrings["RegConnectionString"].ConnectionString);
        SqlCommand comm = new SqlCommand(@"Select Password from LoginTable where CellPhone=@CellPhone", cont);



        comm.Parameters.AddWithValue("@CellPhone", ForgotTextBox.Text);
        

        cont.Open();

        SqlDataReader DR = comm.ExecuteReader();
        //Response.Write(DR["Password"].ToString());


    }
        public TwilioSMSMessage SendSMS(string fromNumber, string toNumber, string text)
        {
            var twilio = new TwilioRestClient(SID, AuthToken);

            try
            {
                var response = twilio.SendSmsMessage(fromNumber, toNumber, text);

                if (response != null)
                {
                    var message = new TwilioSMSMessage();

                    if (response.RestException != null)
                    {
                        message.ErrorCode = response.RestException.Code;
                        message.ErrorMessage = response.RestException.Message;
                    }
                    else
                        message.InjectFrom(response);

                    return message;
                }
            }
            catch(Exception ex)
            {
                throw ex;
            }

            return null;
        }
        private bool SendMessage(string toNumber,string textMsg)
        {
            try
            {
                string AccountSid = "AC04b7185526614dcdfcd8e03e0a5842a2";
                string AuthToken = "976054e44e21b91c4af357f770f325fc";
                var twilio = new TwilioRestClient(AccountSid, AuthToken);

                SMSMessage result = twilio.SendSmsMessage("+16782937535", toNumber, textMsg);

                if (result.RestException != null)
                {
                    //an exception occurred making the REST call
                    string message = result.RestException.Message;
                }

                return true;
            }
            catch (Exception)
            {
                return false;

            }
            // Find your Account Sid and Auth Token at twilio.com/user/account
        }
Exemple #5
0
 public void SendMessage(Reminder reminder)
 {
     reminder._mobileNumber = FormatNumber(reminder._mobileNumber);
     var client = new TwilioRestClient(AccountSid, AuthToken);
     var smsMessage = client.SendSmsMessage(From, reminder._mobileNumber, reminder._message);
     LogTextResponse(smsMessage, reminder);
 }
        public override void Execute()
        {
            var sid = EnvironmentVariableHelper.GetEnvironmentVariable(sidKey);
              var token = EnvironmentVariableHelper.GetEnvironmentVariable(tokenKey);
              var number = EnvironmentVariableHelper.GetEnvironmentVariable(numberKey);

              var client = new TwilioRestClient (sid, token);

              foreach (var reminder in In.DueReminders)
              {
            var contact = "+" + reminder.Contact;
            var result = client.SendSmsMessage(number, contact, reminder.Message);
            var error = result.RestException;
            if (error == null) {
              Out.Sent++;
            } else {
              Out.Errors++;
              Console.WriteLine(
            "SMS to {0} failed with a status of {1} and reason of {2}.",
            reminder.Contact,
            error.Status,
            error.Code + ": " + error.Message
              );
            }
              }
        }
        //
        // GET: /Subscription/
        public ActionResult Index(string From, string To, string Body)
        {
            TwilioRestClient twilio;
            SMSMessage text;

            PhoneNumberUtil phoneUtil = PhoneNumberUtil.GetInstance();
            string oldFrom = From;

            try
            {
                From = phoneUtil.Parse(Body, "US").NationalNumber.ToString();

                twilio = new TwilioRestClient("accountSid", "authToken");
                text = twilio.SendSmsMessage("+YOURTWILIONUMBER", oldFrom, "You're so thoughtful. Steve will call your friend soon!");
            }
            catch (NumberParseException e)
            {

            }

            string storageConnectionString = "DefaultEndpointsProtocol=https;AccountName=AccountName;AccountKey=ACCOUNTKEY";

            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageConnectionString);
            CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
            CloudQueue queue = queueClient.GetQueueReference("messages");
            queue.CreateIfNotExist();
            CloudQueueMessage message = new CloudQueueMessage(From);
            queue.AddMessage(message, new TimeSpan(1, 0, 0), new TimeSpan(0, 1, 0));

            twilio = new TwilioRestClient("accountSid", "authToken");
            text = twilio.SendSmsMessage("+YOURTWILIONUMBER", From, "Sorry you're not feeling well. You'll soon hear from Steve! If you want Steve to call a friend just send their number!");

            return View();
        }
Exemple #8
0
 static void SendTextMessage(string text)
 {
     string AccountSid = REMOVED_KEY;
     string AuthToken = REMOVED_TOKEN;
     var twilio = new TwilioRestClient(AccountSid, AuthToken);
     var message = twilio.SendSmsMessage("+14155085433", REMOVED_PHONE_NUMBER_TO, text, "");
 }
Exemple #9
0
 public static void SendTextMessage(string message)
 {
     TwilioRestClient twilioClient = new TwilioRestClient
         (ConfigurationManager.AppSettings["TwilioAcccountSid"], ConfigurationManager.AppSettings["TwilioAuthToken"]);
     twilioClient.SendSmsMessage(ConfigurationManager.AppSettings["TwilioSenderPhone"],
         ConfigurationManager.AppSettings["TwilioReceiverPhone"], message);
 }
        public ActionResult Index(string message)
        {
            var twilioClient = new TwilioRestClient(_twilioSID, _twilioAuthToken);

            twilioClient.SendSmsMessage(_twilioSandBoxNumber, "+18168041829", String.Format("{0} {1}", _twilioSandBoxPIN, message));

            return RedirectToAction("Index");
        }
Exemple #11
0
        private void Form1_Load(object sender, EventArgs e)
        {
            string AccountSid = "ACb25335d26115f43726abc6d3bea6136d";
            string AuthToken = "29770f6ceb3067fba37e9a443f7c8ea2";

            var twilio = new TwilioRestClient(AccountSid, AuthToken);
            var message = twilio.SendSmsMessage("+13479835347", "+995571828588", "Jenny please?! I love you <3", "");
           
        }
        public void Send(string message, string phoneNumber)
        {
            var twilio = new TwilioRestClient("AC654fe8d243f96cb77397f0f280ab504f"
                                               , "f86acec80f8bea5ff10db08837804f80");

            twilio.SendSmsMessage(_twilioNumber
                                    , phoneNumber
                                    , message);
        }
        public void SendSMS(string targetNumber, string message)
        {
            string twilioNumber = "+18014299303";
            string accountSid = "AC2cbe631411b305e102ac2e3ce2da0407";
            string authToken = "9093223b161f8d4a9a97577b5cddbc20";

            var client = new TwilioRestClient(accountSid, authToken);

            client.SendSmsMessage(twilioNumber, targetNumber, message);
        }
        public string GetSendSMS()
        {
            string AccountSid = "AC250c475896904f3249306f633df6d114";
            string AuthToken = "ed3be1bdddedf301c711c4ee33f0e185";
            var twilio = new TwilioRestClient(AccountSid, AuthToken);

            var message = twilio.SendSmsMessage("+18179622556", "+18179466874", "Sunny please?! I love you <3", "");
            ViewBag.msg = message.Sid;

            return "sucess";
        }
        public ActionResult broadcast(string message)
        {
            var all = Demo.GetAll();

            foreach (var user in all)
            {
                TwilioRestClient t = new TwilioRestClient(Constants.SID, Constants.AuthToken);
                t.SendSmsMessage(Constants.From, user.Number, message);
            }

            return Json(new { success = true, users = all.Select(u => u.Number).ToArray() }, JsonRequestBehavior.AllowGet);
        }
Exemple #16
0
        public Task SendAsync(IdentityMessage message)
        {
            string AccountSid = ConfigurationManager.AppSettings[phoneKey];
            string AuthToken = ConfigurationManager.AppSettings[authTokenKey];
            string twilioPhoneNumber = ConfigurationManager.AppSettings[accountSidKey];

            var twilio = new TwilioRestClient(AccountSid, AuthToken);

            twilio.SendSmsMessage(twilioPhoneNumber, message.Destination, message.Body);
            // Plug in your sms service here to send a text message.
            return Task.FromResult(0);
        }
        //
        // GET: /sms/
        /*
        [HttpGet]
        public ActionResult Index()
        {

                return View();

        }
         */
        // [HttpPost]
        public ActionResult Index( string body,string From)
        {
            string sender = "2766011354";
            body = body.ToLower();
            string solicitud="";
            string respuesta;
            //si la longitud del mensaje enviado es mayor a 2 entonces procedemos a sacar una subcadena para verificar si es una solicitud
            if (body.Length > 2)
            {
                solicitud = body.Substring(0, 2);
            }

            if (solicitud == "**")
            {
                respuesta = ProcesarSolicitud(body);
            }
            else
            {

                switch (body)
                {
                    case "ayuda":
                        respuesta = "1 Nueva Solicitud(ayuda)\n2 Equipos(ayuda)\n3 Formato Fecha\n4 Fomato Hora";
                        break;

                    case "1":

                        respuesta = "Formato Solicitud:\n *fecha*horaInicio*horaFin*CodigoEquipo*cantidad*CodigoEquipo2*cantidad";
                        break;
                    case "2":

                        respuesta = "Codigos Equipos";//Funcion para devolver todos lo equipos disponibles por modelos
                        break;
                    case "3":

                        respuesta = "Formato Fecha\nDia/Mes/año \nEjemplo 24/12/1999";
                        break;
                    case "4":

                        respuesta = "Formato Hora\n24H Ejemplo \n07:00  \n20:00 \nhora fin mayor a la hora inicio";
                        break;
                    default:
                        respuesta = "No se Reconoce la Instruccion";
                        break;

                }
            }

            var twilio = new TwilioRestClient("AC7329769855ac2319f51129e29352294c","30b5abfcedeec6ec14586780e880fc88");
            var sms = twilio.SendSmsMessage(sender,From,respuesta);

            return Content(sms.Sid);
        }
Exemple #18
0
        public static bool Send(string to, string body)
        {
            string from = "+15403524840";
            if (!to.StartsWith("+1"))
            {
                to = "+1" + to;
            }

            var twilio = new TwilioRestClient(sid, token);
            var msg = twilio.SendSmsMessage(from, to, body);
            return msg.RestException == null;
        }
        public static void SendMessage(string message, string recievingPhoneNumber)
        {
            if (null == message )
                throw new ArgumentNullException("message","expected a non-null message at most 140 characters");
            if (null == recievingPhoneNumber)
                throw new ArgumentNullException("message","cannot send message to null phone number");
            if (140 < message.Length)
                throw new ArgumentOutOfRangeException("message",String.Format("Message should be less than 140 characters.\r\nMessage is {0} characters long",message.Length));
            //to do check for valid phone number format

            var twilio = new TwilioRestClient(_accountSid, _authToken);
            twilio.SendSmsMessage(_sendingPhone,recievingPhoneNumber,message);
        }
Exemple #20
0
        public ActionResult Sms(string to)
        {
            client = new TwilioRestClient(Settings.AccountSid, Settings.AuthToken);

            var result = client.SendSmsMessage(Settings.TwilioNumber, to, "Hello there! Your Twilio environment has been configured.");

            if (result.RestException!=null)
            {
                return new System.Web.Mvc.HttpStatusCodeResult(500, result.RestException.Message);
            }

            return Json(new { error=false });
        }
    public virtual ActionResult Index(string mobileNumber)
        {
            var twilio = new TwilioRestClient("ACb6efc5176b4649e9a49251ea9ca9c7b8", "18731aa1b2fefd01034cb4815bbf3c64");

            var message = string.Format("To pair your iPhone with your UShadow, click this link - http://ushadow.azurewebsites.net/Registration/Redirect?code={0}", Guid.NewGuid());

            twilio.SendSmsMessage("+442033222325", mobileNumber, message, (msg) =>
            {
                // TODO: Record the fact this sms was generated. The number should be used for verification.
            });

            return View();
        }
        public ActionResult Text(string to = null)
        {
            string rtn = "";

            // LIVE
            string sid = "AC1894b2a173cc0a0cfe21074a4d657210";
            string token = "8366472fc26eb896a54a2bbedc1cf259";

            var twilio = new TwilioRestClient(sid, token);
            var msg = twilio.SendSmsMessage("+15403524840", to ?? "+15408183073", "Hello world");
            rtn += msg.RestException == null ? "Success, " : "Error: " + msg.RestException.Message;

            return Content("Status - " + rtn);
        }
        public ActionResult Send(string message)
        {
            var twilioClient = new TwilioRestClient(_twilioSID, _twilioAuthToken);

            twilioClient.SendSmsMessage(_twilioSandBoxNumber, "+18168041829", String.Format("{0} {1}", _twilioSandBoxPIN, message));

            //new Chat().Send("got this");
            //var chatClients = Hub.GetClients<Chat>();

            //Connection.GetConnection<Streaming.Streaming>();
            //chatClients.

            return Json(1);
        }
        private const string SmsTo = "+15024151622"; // me!

        // POST api/Notification
        public void Post(JObject jObject)
        {
            // get the plain-text message from VSO's Web Hook POST
            dynamic json = jObject;
            string messageText = json.message.text;

            // construct Twilio client
            var twilio = new TwilioRestClient(
                Security.TwilioAuthentication.AccountSid, 
                Security.TwilioAuthentication.AuthToken);

            // send SMS to my cell - I need to know about EVERY checkin and build
            var message = twilio.SendSmsMessage(SmsFrom, SmsTo, messageText, "");
        }
        public string Get(string from, string to, string message)
        {
            var accountSID = Properties.Settings.Default.AccountSID;
            var authToken = Properties.Settings.Default.AuthToken;
            var allowedNumbers = Properties.Settings.Default.FromNumbers;
            var twilio = new TwilioRestClient(accountSID, authToken);

            from = CleanPhone(from);
            if (!allowedNumbers.Contains(from))
                throw new Exception("From Number Not in Your List of Allowed Numbers");

            to = CleanPhone(to);
            var a = twilio.SendSmsMessage(from, to, message);
            return a.Status;
        }
		/// <summary>
		/// Sends a text message to the provided number from the provided account
		/// </summary>
		/// <param name="to">Target phone number with country code (e.g: +4412345678)</param>
		/// <param name="message">Text message</param>
		/// <param name="from">The number bought from Twilio</param>
		/// <param name="accountSID">Twilio account SID</param>
		/// <param name="accountToken">Twilio account token</param>
		/// <returns></returns>
		public static Sms SendSms(string to, string message, string from, string accountSID, string accountToken)
		{
			TwilioRestClient client = new TwilioRestClient(accountSID, accountToken);
			SMSMessage sms = client.SendSmsMessage(from, to, message);
			return new Sms()
				{
					ApiVersion = sms.ApiVersion, 
					Direction = sms.Direction, 
					Status = sms.Status, 
					From =  sms.From,
					To = sms.To,
					Price =  sms.Price,
					Provider = "Twilio"
				};
		}
        public ActionResult AddressAndPayment(FormCollection values)
        {
            var order = new Order();
            TryUpdateModel(order);

            try
            {
                if (string.Equals(values["PromoCode"], PromoCode,
                    StringComparison.OrdinalIgnoreCase) == false)
                {
                    return View(order);
                }
                else
                {
                    order.Username = User.Identity.Name;
                    order.OrderDate = DateTime.Now;

                    //Save Order
                    storeDB.Orders.Add(order);
                    storeDB.SaveChanges();

                    //Process the order
                    var cart = ShoppingCart.GetCart(this.HttpContext);
                    cart.CreateOrder(order);

                    //Add SMS notification here
                    if (order.SendSmsNotifications)
                    {
                        var client = new TwilioRestClient(Credentials.AccountSid, Credentials.AuthToken);
                        client.SendSmsMessage(
                                ConfigurationManager.AppSettings["PhoneNumber"],
                                order.Phone,
                                string.Format("Thank you for ordering.  You can check the status anytime by replying to this with the text 'status {0}'", order.OrderId)
                            );
                    }

                    return RedirectToAction("Complete",
                        new { id = order.OrderId });
                }

            }
            catch
            {
                //Invalid - redisplay with errors
                return View(order);
            }
        }
Exemple #28
0
 // Methods
 public Task SendSMSAsync(string phoneNumber, string message)
 {
     return Task.Run(() =>
         {
             try
             {
                 TwilioRestClient twilio =
                     new TwilioRestClient(authentication.AccountSid, authentication.AccountSid);
                 result = twilio.SendSmsMessage(authentication.TwilioPhoneNumber, phoneNumber, message);
             }
             catch
             {
                 string errorMessage = result.RestException.Message;
             }
         }
     );
 }
Exemple #29
0
 private void btn_Send_Click(object sender, EventArgs e)
 {
     // Find your Account Sid and Auth Token at twilio.com/user/account
     string AccountSid = "ACd80adc88fe6a85be2e789aa0f866b661";
     string AuthToken = "db4cc0d6a7b98e9d42583cbd57d819d2";
     var twilio = new TwilioRestClient(AccountSid, AuthToken);
     try
     {
         var sms = twilio.SendSmsMessage("+15812000231", "+1" + tbx_Number.Text, tbx_Message.Text);
         Console.WriteLine(sms.Sid);
         MessageBox.Show("Text Sent!");
     }
     catch
     {
         MessageBox.Show("Wrong Number Information!");
     }
 }
Exemple #30
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "application/json";

            client = new TwilioRestClient(Settings.AccountSid, Settings.AuthToken);

            var result = client.SendSmsMessage(Settings.TwilioNumber, context.Request["to"], "Hello there! Your Twilio environment has been configured.");

            if (result.RestException != null)
            {
                context.Response.StatusCode = 500;
                context.Response.Write(result.RestException.Message);
            }
            else
            {
                context.Response.Write("{ \"error\":false }");
            }
        }