【问题标题】:posting message on twitter using tweetinvi does not consistently publish the tweet使用 tweetinvi 在 Twitter 上发布消息不会始终如一地发布推文
【发布时间】:2017-05-30 10:01:52
【问题描述】:

我有一个用户列表,我需要在 Twitter 上发布消息(在我们的帐户上发布消息,然后使用 @ID 引用这些用户),使用 tweetinvi。目前,这是我的代码。我正在尝试每 36 秒发布一条消息,以获得每天可能的最大推文数量 (2400)。

    static void Main(string[] args)
    {
        
        allUsers = analytics.getAllUniqueUserID();
       

       
        System.Timers.Timer aTimer = new System.Timers.Timer();
        aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
        
        aTimer.Interval = 36000;
        aTimer.Enabled = true;

        while (true)
        {
            //just to keep console open
        }
    }

定时事件如下

private static void OnTimedEvent(object source, ElapsedEventArgs e)
    {

        lastMessaged = analytics.getLastUserIDMessaged() + 1;
        string identifier = allUsers[lastMessaged];
        string message = "Hello";
        
        TwitterAccess.publicTweetToUsers(identifier, message); 
        analytics.writeLastIDToFile(lastMessaged.ToString());
        
        
        
    }

与 publicTweetToUsers 如下

public static void publicTweetToUsers(string identifier, string message)
    {
        Auth.SetUserCredentials(key, secret, token, tokenSecret);
        var user = User.GetAuthenticatedUser();

        var tweet = Tweet.PublishTweet(string.Format("{0} {1}",     identifier, message));

    }

请注意,key、secret、token 和 tokenSecret 是赋值的,并且该帐户确实会登录并发送推文,但它不会始终如一地这样做,它会发送一段时间然后停止。我做错了什么?

【问题讨论】:

    标签: c# tweetinvi


    【解决方案1】:

    我是 Tweetinvi 的开发者。

    正如您提到的,Twitter 每天授权的推文的理论限制是每天 2400 条,以 30 分钟为单位(每 30 分钟 50 条)。

    虽然为了防止 twitter 上的垃圾邮件,他们的服务器会应用未记录的测试来确保推文是“合法”推文。

    因此,在我们认为问题来自图书馆之前,让我们分析一下 Twitter 返回的内容,并尝试稍微减少您每天发布的推文数量。

    1. 将计时器增加到 0.5 秒(1440 条推文/天)。
    2. 查看 Twitter (https://github.com/linvi/tweetinvi/wiki/Exception-Handling#per-request-exception-handling) 返回的错误

    在错误中,您会发现 2 个有用的属性:TwitterExceptionInfosTwitterDescription。如果这 2 个属性不能真正帮助您识别问题,请在TwitterException 中分享所有可用信息,我会仔细研究它们。

    周末愉快!

    【讨论】:

    • 感谢您的回复。不知何故,我的程序找不到那篇文章中提到的 TwitterException,它只是说缺少命名空间......我是否错误地添加了 tweetinvi?使用 Visual Studio 2010:固定 xD 忘记使用 Tweetinvi.Exceptions 添加;
    • 工作完美,更改每 60 秒发送一次的延迟似乎已经成功,在此过程中还升级到更新版本的 tweetinvi,非常感谢您的回复!
    猜你喜欢
    • 2011-09-13
    • 1970-01-01
    • 1970-01-01
    • 2020-03-05
    • 2017-02-08
    • 2021-08-03
    • 2023-04-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多