dthree
dthree

Reputation: 20740

Twilio Node.js API date format

I am trying to get a message list from Twilio's Node.js API. I want all messages that were sent at a date greater or equal to the given date:

client.messages.list({
  dateSent: '>=2013-10-04',
}, function(err, data) {
  if (err) {
    console.log(err);
  } else {
    data.messages.forEach(function(message) {
      console.log(message.body);
    });
  }
});

Getting an absolute date sent is easy and this works, but in the docs it says:

Here, under 'list filters' it states:

Only show messages sent on this date (in GMT format), given as YYYY-MM-DD. Example: DateSent=2009-07-06. You can also specify inequality, such as DateSent<=YYYY-MM-DD for messages that were sent on or before midnight on a date, and DateSent>=YYYY-MM-DD for messages sent on or after midnight on a date.

So that applies to a URL param, but I don't know how to pass this as a JSON param with the client object....

I asked Twilio support but no answer...

Upvotes: 1

Views: 498

Answers (1)

dthree
dthree

Reputation: 20740

Twilio answered me. This is the right syntax:

client.messages.list({
  'dateSent>': '2013-10-04',
}, function(err, data) {
  if (err) {
    console.log(err);
  } else {
    data.messages.forEach(function(message) {
      console.log(message.body);
    });
  }
});

Upvotes: 3

Related Questions