I'm using the latest stable built of TweetSharp from codeplex in a VS2008 C# project. I'm writing the project in terms of TwitterService not FluentTwitter.
I have an application that authenticates, then acts as a listener. It sits around and polls Twitter at regular interval looking for direct messages. After I have fetched the latest direct messages (which works fine), I process开发者_开发问答 them and do stuff, then I want to remove them from my inbox, so I never reprocess them again.
The first place I looked was TwitterServer.DeleteDirectMessage(int msgId), however, since I didn't author the DMs, I clearly can't delete them. I know there is a way to do this, because if you log in to the Twitter webpage you can simply delete DMs one by one from your inbox.
Two questions: 1. How to delete DMs from my inbox? 2. Where is complete documentation? (Apologies if this is obvious and I missed it, but it's not under the "Documentation" tab on TweetSharp's codeplex site. The only thing under "Documentation" is several primitive examples.)
//Authenticate...
//Declarations:
string message = null;
List<string> messages = new List<string>();
IEnumerable<TwitterDirectMessage> directMessages = service.ListDirectMessagesReceived();
//Fetch all current direct message:
foreach (TwitterDirectMessage directMessage in directMessages)
{
//Store each message into a list, in reverse older:
message = /*"[" + directMessage.CreatedDate.ToString() + "]" +*/ directMessage.Text;
messages.Insert(0, message);
//Delete each DM to ensure that is is never fetched again:
// ??
}
//Do stuff with DMs
Do you really want to delete DMs from the server? What if the user will go back to twitter.com and want to look them up there?
Another approach could be for you to keep track of DMs that have been displayed before and filter them out later on the client side before re-processing.
精彩评论