我有一个用户列表,我需要在 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 被分配了值,并且该帐户确实登录并发送了推文,但它并没有始终如一地这样做,它会发送一段时间然后停止。我究竟做错了什么 ?