Closed knight7024 closed 7 years ago
Hi,
I can't tell from your code whether you're using it incorrectly or not. Your posted code just shows you reading the value of IsRetweeted or IsFavorited into new boolean variables. That code is correct for what it does, but gives no context about the problem you're having so I have no idea why the values 'always return false' for you.
I put the following code in a new .net 4.0 console project, added my own app & user credentials, and it works fine (returns 2 tweets retweeted and 8 favourited, which is correct for the last 200 tweets on my timeline right now);
var consumerKey = "yourappkey";
var consumerSecret = "yourappsecret";
var userKey = "youraccesstoken";
var userSecret = "youraccesstokensecret";
var service = new TweetSharp.TwitterService(consumerKey, consumerSecret, userKey, userSecret);
var tweetsOnTimeline = service.ListTweetsOnHomeTimeline(new TweetSharp.ListTweetsOnHomeTimelineOptions() { Count = 200 });
Console.WriteLine((from t in tweetsOnTimeline where t.IsRetweeted select t).Count() + " Tweets Retweeted by me");
Console.WriteLine((from t in tweetsOnTimeline where t.IsFavorited select t).Count() + " Tweets Favourited by me");
Console.ReadLine();
In your case:
IsRetweeted and IsFavorited means "I have retweeted this' or "I have favorited this", not has anyone done so. Maybe you misunderstand what they mean?
Alternatively, maybe you have only authorised with a consumer key and no user token, in which case the values will always be false because the system doesn't know who you are and therefore cannot say if you retweeted/favourited.
Maybe you have authroised your app with credentials for a different user than the account you did the favourite/retweet with?
Maybe you obtained the tweets, then retweeted/favourited and did not get the tweets again? The tweet objects do not update, so you will need to re-retrieve them if the state changes after you first get them.
Also, Twitter is an 'eventually consistent' cloud system, so maybe if Twitter is busy and you retrieve the tweet very soon after you favourite/retweet then the state won't have changed yet.
Hi,
Did you manage to resolve this?
if (tweet.IsQuoteStatus)
{
AddReTwt(HttpUtility.HtmlDecode(tweet.RetweetedStatus.Text), tweet.RetweetedStatus.Author.ProfileImageUrl, tweet.RetweetedStatus.User.Name, tweet.User.ScreenName, tweet.User.Name, "@" + tweet.RetweetedStatus.User.ScreenName, tweet.RetweetedStatus.CreatedDate.ToLocalTime().ToString("t"), tweet.IdStr, tweet.IsRetweeted, tweet.IsFavorited, tweet.IsQuoteStatus, tweet.QuotedStatus.Text, tweet.QuotedStatus.User.Name, tweet.QuotedStatus.User.ScreenName);
}
else
{
AddReTwt(HttpUtility.HtmlDecode(tweet.RetweetedStatus.Text), tweet.RetweetedStatus.Author.ProfileImageUrl, tweet.RetweetedStatus.User.Name, tweet.User.ScreenName, tweet.User.Name, "@" + tweet.RetweetedStatus.User.ScreenName, tweet.RetweetedStatus.CreatedDate.ToLocalTime().ToString("t"), tweet.IdStr, tweet.IsRetweeted, tweet.IsFavorited, tweet.IsQuoteStatus, string.Empty, string.Empty, string.Empty);
}
I used like this, tweet.IsRetweeted and tweet.IsFavorited are parametized and sent to AddReTwt function. And that source is in UserStreaming function.
But it always returns false I already added access token and secret
Hi, Sorry, still not clear to me what you are trying to do. Is the user stream you're listening to the same user as you've authorised the service with? IsRetweet and IsFavourite will only be set if you retrieve the tweet after that action has taken place, as the user who performed the action.
Could you provide the .Raw property of a tweet that you think should have these as true? The raw property returns the raw json returned from Twitter, so that will prove if the library is not properly parsing the response from Twitter, or if Twitter is actually sending false/missing values.
Also, after you get the stream event, if you retrieve the same tweet using GetTweet, does the tweet returned from GetTweet have these set to true? Maybe the tweet in the stream is captured by Twitter before the status change, and the event status indicates that it was retweeted/favourited? I haven't done much with streams.
For example, this code returns IsRetweeted both for the 'retweet' and 'updatedstatus' objects, so it clearly works outside a stream when Twitter returns the expected values;
var service = GetAuthenticatedService();
var status = _hero + DateTime.UtcNow.Ticks + " Tweet from TweetSharp unit tests";
var tweet = service.SendTweet(new SendTweetOptions { Status = status });
var retweet = service.Retweet(new RetweetOptions() { Id = tweet.Id });
var updatedStatus = service.GetTweet(new GetTweetOptions() { Id = retweet.Id });
AssertResultWas(service, HttpStatusCode.OK);
Assert.IsNotNull(updatedStatus);
Assert.AreEqual(true, updatedStatus.IsRetweeted);
Closing as no response. If you have more information or a repro case/project please feel free to re-open.
hi ! there are a difference between the two methods "isretweeted()" and "isretweet()" try with the second method that had given good result for me.
these are always return 'false' though I did retweet. is this incorrect use?
and how can i load mute list? 'TwitterService.ListMutedUsers' returns 'long' type unlike 'TwitterService.ListBlockedUsers'.
:) sorry for my terrible English