当前位置: 首页>>代码示例>>C#>>正文


C# TwilioRestClient.SendMessage方法代码示例

本文整理汇总了C#中Twilio.TwilioRestClient.SendMessage方法的典型用法代码示例。如果您正苦于以下问题:C# TwilioRestClient.SendMessage方法的具体用法?C# TwilioRestClient.SendMessage怎么用?C# TwilioRestClient.SendMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Twilio.TwilioRestClient的用法示例。


在下文中一共展示了TwilioRestClient.SendMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SendAsync

        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
        }
开发者ID:rohitiscancerian,项目名称:VGWagers,代码行数:28,代码来源:SMSService.cs

示例2: SendSMS

        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;
        }
开发者ID:sgh1986915,项目名称:.net-braintree-spa,代码行数:33,代码来源:TwilioSmsSender.cs

示例3: SendSms

        public static void SendSms(string to, string message) {


            var twilio = new TwilioRestClient(TwilioAccountSid, TwilioAuthToken);
            twilio.SendMessage(FromNumber, to, message);

        }
开发者ID:Nbhaskell,项目名称:11-MeetupReminder,代码行数:7,代码来源:SmsService.cs

示例4: Page_Load

        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, "");
        }
开发者ID:niofire,项目名称:Tingo,代码行数:29,代码来源:SmsReceiver.aspx.cs

示例5: SendSms

        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);
        }
开发者ID:mbgreen,项目名称:GHV,代码行数:7,代码来源:TwilioHelper.cs

示例6: SendSMS

        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";
        }
开发者ID:letmeproperty,项目名称:callcentre,代码行数:25,代码来源:TwilioSmsController.cs

示例7: Get

        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);
        }
开发者ID:wadewegner,项目名称:daily-affirmation,代码行数:29,代码来源:TwilioController.cs

示例8: SendSmsMessage

 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);
 }
开发者ID:lshain,项目名称:Zuma,代码行数:7,代码来源:Complex2.cs

示例9: Main

        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");
                    }
                }
            }
        }
开发者ID:mplacona,项目名称:TwilioQueuesMac,代码行数:27,代码来源:Program.cs

示例10: SendSmsToAllInvolved

        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, "");
                }

            }
        }
开发者ID:Cornevur,项目名称:IstokDoorsProject,代码行数:28,代码来源:MethodsForOrderHandling.cs

示例11: OnTimer

        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);
            }
        }
开发者ID:devopsguys,项目名称:DogTrainingWindowsService,代码行数:28,代码来源:DogTrainingWindowsService.cs

示例12: SendMessage

        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);
            }
        }
开发者ID:brentschooley,项目名称:marketing-notifications-csharp,代码行数:17,代码来源:Subscriber.cs

示例13: SendText

        //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);
        }
开发者ID:200even,项目名称:Byrth,代码行数:9,代码来源:SMSController.cs

示例14: SendHospital

        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", "");
        }
开发者ID:seeyouu87,项目名称:HangOver,代码行数:8,代码来源:GeneralController.cs

示例15: SendSms

        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);
        }
开发者ID:shturner20,项目名称:EContact,代码行数:9,代码来源:SmsHandler.cs


注:本文中的Twilio.TwilioRestClient.SendMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。