使用 TweetSharp 删除收件箱消息

发布于 2024-10-11 01:24:43 字数 1217 浏览 2 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

此生挚爱伱 2024-10-18 01:24:43

您确实要从服务器中删除 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文