public ActionResult GetMessages() { var twilio = new TwilioRestClient(AccountSid, AuthToken); // Build the parameters var options = new MessageListRequest(); var ListMessagesResponse = twilio.ListMessages(options); return View(ListMessagesResponse); }
/// <summary> /// Returns a filtered list of Messages. The list includes paging information. /// Makes a GET request to the Messages List resource. /// </summary> /// <param name="options">The list filters for the request</param> public virtual void ListMessages(MessageListRequest options, Action<MessageResult> callback) { var request = new RestRequest(); request.Resource = "Accounts/{AccountSid}/Messages.json"; AddMessageListOptions(options, request); ExecuteAsync<MessageResult>(request, (response) => callback(response)); }
/// <summary> /// Returns a filtered list of Messages. The list includes paging information. /// Makes a GET request to the Messages List resource. /// </summary> /// <param name="options">The list filters for the request</param> public virtual MessageResult ListMessages(MessageListRequest options) { var request = new RestRequest(); request.Resource = "Accounts/{AccountSid}/Messages.json"; AddMessageListOptions(options, request); return Execute<MessageResult>(request); }
/// <summary> /// Add the options to the request /// </summary> private void AddMessageListOptions(MessageListRequest options, RestRequest request) { if (options.To.HasValue()) { request.AddParameter("To", options.To); } if (options.From.HasValue()) { request.AddParameter("From", options.From); } // Construct the date filter if (options.DateSent.HasValue) { var dateSentParameterName = GetParameterNameWithEquality(options.DateSentComparison, "DateSent"); request.AddParameter(dateSentParameterName, options.DateSent.Value.ToString("yyyy-MM-dd")); } // Paging options if (options.PageNumber.HasValue) { request.AddParameter("Page", options.PageNumber.Value); } if (options.Count.HasValue) { request.AddParameter("PageSize", options.Count.Value); } }
/// <summary> /// Returns a filtered list of Messages. The list includes paging information. /// Makes a GET request to the Messages List resource. /// </summary> /// <param name="options">The list filters for the request</param> public MessageResult ListMessages(MessageListRequest options) { var request = new RestRequest(); request.Resource = "Accounts/{AccountSid}/Messages.json"; AddMessageListOptions(options, request); return(Execute <MessageResult>(request)); }
/// <summary> /// Returns a filtered list of Messages. The list includes paging information. /// Makes a GET request to the Messages List resource. /// </summary> /// <param name="options">The list filters for the request</param> public virtual void ListMessages(MessageListRequest options, Action <MessageResult> callback) { var request = new RestRequest(); request.Resource = "Accounts/{AccountSid}/Messages.json"; AddMessageListOptions(options, request); ExecuteAsync <MessageResult>(request, (response) => callback(response)); }
/// <summary> /// Returns a filtered list of Messages. The list includes paging information. /// Makes a GET request to the Messages List resource. /// </summary> /// <param name="options">The list filters for the request</param> public virtual async Task <MessageResult> ListMessagesAsync(MessageListRequest options) { var request = new RestRequest(); request.Resource = "Accounts/{AccountSid}/Messages.json"; AddMessageListOptions(options, request); return(await Execute <MessageResult>(request)); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; var twilio = new TwilioRestClient(AccountSid, AuthToken); var request = new MessageListRequest(); var messages = twilio.ListMessages(request); foreach (var message in messages.Messages) { Console.WriteLine(message.Body); } }
/// <summary> /// Add the options to the request /// </summary> private void AddMessageListOptions(MessageListRequest options, RestRequest request) { if (options.To.HasValue()) request.AddParameter("To", options.To); if (options.From.HasValue()) request.AddParameter("From", options.From); // Construct the date filter if (options.DateSent.HasValue) { var dateSentParameterName = GetParameterNameWithEquality(options.DateSentComparison, "DateSent"); request.AddParameter(dateSentParameterName, options.DateSent.Value.ToString("yyyy-MM-dd")); } // Paging options if (options.PageNumber.HasValue) request.AddParameter("Page", options.PageNumber.Value); if (options.Count.HasValue) request.AddParameter("PageSize", options.Count.Value); }
static void Main(string[] args) { // Find your Account Sid and Auth Token at twilio.com/user/account string AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; string AuthToken = "your_auth_token"; var twilio = new TwilioRestClient(AccountSid, AuthToken); var request = new MessageListRequest { To = "+15558675309", From = "+15017250604", DateSent = new DateTime(2016, 8, 31), DateSentComparison = ComparisonType.GreaterThanOrEqualTo }; var messages = twilio.ListMessages(request); foreach (var message in messages.Messages) { Console.WriteLine(message.Body); } }
//method to get sms from Twilio public static string GetSms() { var twilio = new TwilioRestClient(accountSid, authToken); // Build the parameters var options = new MessageListRequest(); List<string> msg = new List<string>(); var messages = twilio.ListMessages(options); foreach (var message in messages.Messages) { if (message.To == twilioPhoneNumber) { msg.Add(message.Body); } } //Get the last sms string smsInput = msg[0]; return smsInput; }