Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set filter for DateSent to getMessages in Java using Twilio REST API

I am trying to retrieve my SMS log using the REST api but I can't figure out how to filter DateSent to be >= or <= than given date.

TwilioRestClient client = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN); 
Map<String, String> filters = new HashMap<String, String>();
filters.put("DateSent", "2014-04-27");
filters.put("To", "+XXXXXXXXX");    
MessageList messages = client.getAccount().getMessages(filters);

According to documentation here https://www.twilio.com/docs/api/rest/message#list-get-filters you are allowed to send >= or <=, but can't figure out where to put the inequality.

like image 564
noelportugal Avatar asked Apr 27 '14 00:04

noelportugal


People also ask

What is Twilio SMS API?

Twilio's SMS API helps you send and manage messages programmatically: To send an outbound SMS, WhatsApp, or Channels message with the API, POST to the Message resource. You'll also use the Message resource to fetch messages and list messages associated with your account.

What is twilio REST API?

The Twilio REST API allows you to query metadata about your account, phone numbers, calls, text messages, and recordings. You can also do some fancy things like initiate outbound calls and send text messages.

How does twilio API work?

Twilio receives the message from the carrier over a dedicated connection between Twilio and that carrier. The message then lands in Twilio's messaging processing stack where Twilio has written software to receive and interpret that message.


1 Answers

That Twilio documentation certainly is incomplete and confusing.

Try this: filters.put("DateSent>", "2014-04-27");

You can even pass two parameters to retrieve messages between dates:

filters.put("DateSent>", "2014-04-20");
filters.put("DateSent<", "2014-04-27");
like image 176
TwHello Inc Avatar answered Sep 22 '22 17:09

TwHello Inc