This project has moved and is read-only. For the latest updates, please go here.

Querying Direct Messages Sent by a User

Gets the latest 20 direct messages sent by a user.

Entity: DirectMessage
Type: DirectMessageType.SentBy
Parameters/Filters:
Name Purpose Type Required
Count Number of direct messages to return; max is 200 int no
IncludeEntities Include Twitter entities (default: true) bool no
MaxID Return direct messages earlier than or equal to this ID ulong no
Page Page to retrieve int no
SinceID Return direct messages later than this ID ulong no

v3.0 Example:
            var dmResponse =
                await
                    (from dm in twitterCtx.DirectMessage
                     where dm.Type == DirectMessageType.SentBy
                     select dm)
                    .ToListAsync();

            if (dmResponse != null)
                dmResponse.ForEach(dm => 
                {
                    if (dm != null && dm.Recipient != null)
                        Console.WriteLine(
                            "Name: {0}, Tweet: {1}",
                            dm.Recipient.ScreenNameResponse, dm.Text);
                });
v2.1 Example:
            var directMessages =
                (from tweet in twitterCtx.DirectMessage
                 where tweet.Type == DirectMessageType.SentBy &&
                       tweet.Count == 2
                 select new
                 {
                     tweet.SenderScreenName,
                     tweet.ID,
                     tweet.Text
                 })
                .ToList();

            directMessages.ForEach(
                dm => Console.WriteLine(
                    "Sender: {0}, ID: {1}, Tweet: {2}",
                    dm.SenderScreenName,
                    dm.ID,
                    dm.Text));

Twitter API: direct_messages/sent

Last edited Nov 29, 2013 at 3:22 AM by JoeMayo, version 13