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


C# Twilio.TwilioRestClient类代码示例

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


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

示例1: 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

示例2: SendMessage

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

示例3: TwilioSMSService

        public TwilioSMSService(IOptions<SmsSettings> smsSettings)
        {
            _smsSettings = smsSettings.Value;
            //TwilioClient.Init(_smsSettings.Sid, _smsSettings.Token);
            _restClient = new TwilioRestClient(_smsSettings.Sid, _smsSettings.Token);

        }
开发者ID:codefordenver,项目名称:shelter-availability,代码行数:7,代码来源:TwilioSMSService.cs

示例4: 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

示例5: SendSms

		/// <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);	
		}
开发者ID:vmhung93,项目名称:twilio-csharp,代码行数:15,代码来源:Twilio.cs

示例6: 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

示例7: 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

示例8: SendTextMessage

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

示例9: 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

示例10: 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

示例11: Index

        //
        // GET: /SendMessages/
        public ActionResult Index()
        {
            bool messages = true;

            while (messages)
            {
                string storageConnectionString = "DefaultEndpointsProtocol=https;AccountName=AccountName;AccountKey=ACCOUNTKEY";

                CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageConnectionString);
                CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
                CloudQueue queue = queueClient.GetQueueReference("messages");
                CloudQueueMessage retrievedMessage = queue.GetMessage();

                if (retrievedMessage == null)
                {
                    messages = false;
                }

                string phone = retrievedMessage.AsString;

                var twilio = new TwilioRestClient("accountSid", "authToken");
                var call = twilio.InitiateOutboundCall("+YOURTWILIONUMBER", phone, "http://YOURSITE.azurewebsites.net/LookupCompliment/");

                queue.DeleteMessage(retrievedMessage);

            }

            return View("Complete!");
        }
开发者ID:yeahren,项目名称:FlatteristSMS,代码行数:31,代码来源:SendMessagesController.cs

示例12: TwilioProvider

        public TwilioProvider(string accountSid, string authToken)
        {
            this.authToken = authToken;
            this.accountSid = accountSid;

            client = new TwilioRestClient(accountSid, authToken);
        }
开发者ID:vipwan,项目名称:CommunityServer,代码行数:7,代码来源:TwilioProvider.cs

示例13: 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

示例14: SendSMS

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

示例15: TwilioCommunicationService

        public TwilioCommunicationService(string accountSid, string authToken, string msgUrl)
        {
            messagingBaseUrl = msgUrl;
            _client = new TwilioRestClient(accountSid, authToken);
            _callOptions = new CallOptions();

        }
开发者ID:mgolois,项目名称:DivineChMS,代码行数:7,代码来源:TwilioCommunicationService.cs


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