【问题标题】:Delete Inbox Messages with TweetSharp使用 TweetSharp 删除收件箱消息
【发布时间】:2011-01-07 14:28:29
【问题描述】:

我在 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

【问题讨论】:

    标签: c# twitter tweetsharp


    【解决方案1】:

    您真的要从服务器中删除 DM 吗?如果用户返回 twitter.com 并想在那里查找它们怎么办?

    另一种方法可能是让您跟踪之前显示的 DM,然后在重新处理之前在客户端过滤掉它们。

    【讨论】:

    • 谢谢。是的,我目前的技巧是在我获取/处理 DM 时存储时间戳。然后,在此之前的所有 DM 都将被视为“已处理”。但是,是的,我真的很想完全删除 DM。我实际上将 Twitter 用作粗略的消息总线。该产品的用户永远不会真正登录到 Twitter,消息历史记录的存储根本不重要。
    猜你喜欢
    • 2015-06-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-03
    • 2014-02-16
    • 2012-02-23
    相关资源
    最近更新 更多