コード例 #1
0
ファイル: Twilio.cs プロジェクト: vmhung93/twilio-csharp
		/// <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);	
		}
コード例 #2
0
    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());


    }
コード例 #3
0
        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;
        }
コード例 #4
0
        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
        }
コード例 #5
0
ファイル: TextService.cs プロジェクト: tswann/remindr
 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);
 }
コード例 #6
0
        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
              );
            }
              }
        }
コード例 #7
0
        //
        // 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();
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: BradRuderman/RainNotice
 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, "");
 }
コード例 #9
0
ファイル: SmsManager.cs プロジェクト: keyvan/MiniHawraman
 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);
 }
コード例 #10
0
        public ActionResult Index(string message)
        {
            var twilioClient = new TwilioRestClient(_twilioSID, _twilioAuthToken);

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

            return RedirectToAction("Index");
        }
コード例 #11
0
ファイル: Form1.cs プロジェクト: d-kakhiani/C_Sharp
        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", "");
           
        }
コード例 #12
0
        public void Send(string message, string phoneNumber)
        {
            var twilio = new TwilioRestClient("AC654fe8d243f96cb77397f0f280ab504f"
                                               , "f86acec80f8bea5ff10db08837804f80");

            twilio.SendSmsMessage(_twilioNumber
                                    , phoneNumber
                                    , message);
        }
コード例 #13
0
        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);
        }
コード例 #14
0
        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";
        }
コード例 #15
0
        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);
        }
コード例 #16
0
ファイル: SmsTwilioService.cs プロジェクト: kdcllc/KDCLLCWeb
        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);
        }
コード例 #17
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);
        }
コード例 #18
0
ファイル: Sms.cs プロジェクト: Letractively/urlme-cc
        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;
        }
コード例 #19
0
        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);
        }
コード例 #20
0
ファイル: HomeController.cs プロジェクト: kwhinnery/jumpstart
        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 });
        }
コード例 #21
0
    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();
        }
コード例 #22
0
        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);
        }
コード例 #23
0
        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);
        }
コード例 #24
0
        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, "");
        }
コード例 #25
0
        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;
        }
コード例 #26
0
		/// <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"
				};
		}
コード例 #27
0
        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);
            }
        }
コード例 #28
0
ファイル: TwilioService.cs プロジェクト: jeddeh/grande-travel
 // 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;
             }
         }
     );
 }
コード例 #29
0
ファイル: Text.cs プロジェクト: h27han/Desktop-Communication
 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!");
     }
 }
コード例 #30
0
ファイル: Sms.ashx.cs プロジェクト: kwhinnery/jumpstart
        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 }");
            }
        }