當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。