Twitter From ASP.NET – Direct Messages
As you continue building up your Twitter application, you’ll eventually want some way of retrieving direct messages sent to you.
In a lot of ways this will be very similar to retrieving the messages from your friends, but there is the optional parameters object that we can pass that will allow us to retrieve a subset of the messages.
The code for retrieving and displaying the direct messages sent to you is remarkably similar to the code we wrote earlier that retrieved the messages sent by our friends. You’ll need to create a class called “Direct” and add a method to it named “Messages” with the following code:
public static TwitterStatusCollection Messages() { String password = HttpContext.Current .Session["Password"].ToString(); String name = HttpContext.Current .User.Identity.Name; return (new Twitter(name, password)) .DirectMessages.DirectMessages(); }
Then you’ll need to bind to it in your display code using a repeater that binds to an ObjectDataSource with the ObjectDataSource configured like this
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="Messages" TypeName="Directs"> </asp:ObjectDataSource>
Using the parameters parameter, you can retrieve messages since a specific ID, messages prior to an ID, a specific number of messages, or a specific page (see previous entries about Twitter programming in the list below) The maximum number of direct messages you can retrieve at any one time is 200.
[...] Twitter From ASP.NET – Direct Messages (Dave) [...]
[...] Twitter From ASP.NET – Direct Messages (Dave) [...]