使用 TweetSharp 删除收件箱消息
我在 VS2008 C# 项目中使用 Codeplex 的最新稳定版 TweetSharp。我正在根据 TwitterService 而不是 FluentTwitter 编写该项目。
我有一个进行身份验证的应用程序,然后充当侦听器。它会定期对 Twitter 进行民意调查,寻找直接消息。在我获取最新的直接消息(效果很好)后,我处理它们并执行一些操作,然后我想将它们从我的收件箱中删除,所以我再也不会重新处理它们。
我首先查看的是 TwitterServer.DeleteDirectMessage(int msgId),但是,由于我没有创作 DM,所以我显然无法删除它们。我知道有一种方法可以做到这一点,因为如果你登录Twitter网页,你可以简单地从收件箱中一一删除DM。
两个问题: 1. 如何从我的收件箱中删除私信? 2. 完整的文档在哪里? (如果这很明显并且我错过了,我很抱歉,但它不在 TweetSharp 的 codeplex 网站上的“文档”选项卡下。“文档”下唯一的东西是几个原始示例。)
//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
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您确实要从服务器中删除 DM 吗?如果用户返回 twitter.com 并想在那里查找它们怎么办?
另一种方法可能是您跟踪之前显示的 DM,并在重新处理之前在客户端将其过滤掉。
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.