// 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);
}
答案 0 :(得分:1)
为什么你的代码如此复杂,因为它可能如下所示:
var tweets = Search.SearchTweets("@Kaanshu7");
var firstTweet = tweets.First();
bool isAvailable = firstTweet.Text.Contains("#ServiceRequest");
if (isAvailable)
{
var retweetMessage = Console.ReadLine();
firstTweet.PublishReply(retweetMessage);
}
你觉得不容易吗?
答案 1 :(得分:0)
twitter API似乎已更改,并且要用tweetinv回复推文,您需要这样做:
var tweet = Search.SearchTweets("stackoverflow");
var textToPublish = $"@{tweet.CreatedBy.ScreenName}";
var reply = Tweet.PublishTweet(new PublishTweetParameters(textToPublish)
{
InReplyToTweet = tweet
});