twilio 列表过滤器选项

twilio list filter options

我正在使用 twilio API 文档中的示例来获取帐户可用的所有消息并将它们保存在本地,使用 SID 作为 PK。我只需要获取新消息(大于发送时间戳?)我在页面上看到有过滤传入消息的选项,但我没有看到 "List Filters" 下发布的如何 "limit the list by providing certain query string parameters to the listing resource" 的示例].

using System;
using Twilio;
class Example 
{
   static void Main(string[] args) 
   {
     // Find your Account Sid and Auth Token at twilio.com/user/account
     string AccountSid = "AC5ef8732a3c49700934481addd5ce1659";
     string AuthToken = "{{ 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);
    }
  }
}

不知道这是否是一个单独的问题,但我还需要仅获取我与消息列表中每个已发送号码的最后一次互动。我已经搜索了 twilio 文档,但可能遗漏了一些内容。如果有人能指出我正确的资源,我将祝福他们未出生的后代。提前致谢。

如何简单地使用 MessageListRequest class 上可用的选项:

using System;
using Twilio;
class Example 
{
   static void Main(string[] args) 
   {
     // Find your Account Sid and Auth Token at twilio.com/user/account
     string AccountSid = "AC5ef8732a3c49700934481addd5ce1659";
     string AuthToken = "{{ auth_token }}";
     var twilio = new TwilioRestClient(AccountSid, AuthToken);

    var request = new MessageListRequest();

    // 10 days ago.
    request.DateSent = (DateTime.UtcNow - TimeSpan.FromDays(10));

    var messages = twilio.ListMessages(request);

    foreach (var message in messages.Messages)
    {
      Console.WriteLine(message.Body);
    }
  }
}

to get greater than "send date" time stamp use MessageListRequest.DateSentComparison

    using System;
    using Twilio;
    class Example 
    {
       static void Main(string[] args) 
       {
         // Find your Account Sid and Auth Token at twilio.com/user/account
         string AccountSid = "AC5ef8732a3c49700934481addd5ce1659";
         string AuthToken = "{{ auth_token }}";
         var twilio = new TwilioRestClient(AccountSid, AuthToken);

        var request = new MessageListRequest();
        // 10 days ago.
        request.DateSent = (DateTime.UtcNow - TimeSpan.FromDays(10));

        // this will do the comparison for greater than or equal to
        request.DateSentComparison = ComparisonType.GreaterThanOrEqualTo;

       // use following if want to do less than or equal to
       //request.DateSentComparison = ComparisonType.LessThanOrEqualTo;

        var messages = twilio.ListMessages(request);

        foreach (var message in messages.Messages)
        {
          Console.WriteLine(message.Body);
        }
      }
    }