无法使用Tweetinvi重播tweet

本文关键字:重播 tweet Tweetinvi | 更新日期: 2023-09-27 18:13:22

    // 1. /*Authentication */
    TwitterCredentials.SetCredentials("", "", "", "");
    var tweets = SearchJson.SearchTweets("@Kaanshu7");
    var js = new JavaScriptSerializer();
    var tweetsSerialize = js.Deserialize<dynamic>(tweets);
    var text = tweetsSerialize["statuses"][0]["text"];
    bool isAvailable = text.Contains("#ServiceRequest");
    if (isAvailable)
    {
        tweet = text;
        tweet_id = tweetsSerialize["statuses"][0]["id"];

        // 2. /*Here trying to Retweet (not posting)*/
        retweet = Console.ReadLine();
        var ReplyTweet = Tweet.CreateTweet(retweet);
        var replyTweet = Tweet.PublishTweetInReplyTo(ReplyTweet, tweet_id);
    }

无法使用Tweetinvi重播tweet

为什么你的代码这么复杂,明明可以这么简单:

var tweets = Search.SearchTweets("@Kaanshu7");
var firstTweet = tweets.First();
bool isAvailable = firstTweet.Text.Contains("#ServiceRequest");
if (isAvailable)
{
    var retweetMessage = Console.ReadLine();
    firstTweet.PublishReply(retweetMessage);
}

你不觉得更容易吗?

似乎twitter API发生了变化,并且要使用tweetinv回复tweet,您需要这样做:

var tweet = Search.SearchTweets("stackoverflow");
var textToPublish = $"@{tweet.CreatedBy.ScreenName}";
var reply = Tweet.PublishTweet(new PublishTweetParameters(textToPublish)
                {
                    InReplyToTweet = tweet
                });