Quantcast
Channel: Tweetinvi a friendly Twitter C# library
Viewing all articles
Browse latest Browse all 4126

New Post: Best practise for tracking Tweets which contain own @ScreenName

$
0
0
Hi MatR,

It depends on what you are willing to do. If the @MyScreenName is really YOUR ScreenName, I would personally use the UserStream because it will include the private tweets.
var us = Stream.CreateUserStream();
us.TweetCreatedByAnyone += (sender, args) =>
{
    var userMentions = args.Tweet.UserMentions;
    if (userMentions != null&& userMentions.Any(x => x.ScreenName == "MY_SCREEN_NAME"))
    {
        // Do whatever
    }
};
us.StartStream();
If you want to get all the public tweets mentioning a specific user screen you can use the FilteredStream.
var fs = Stream.CreateFilteredStream();
fs.AddTrack("@MY_SCREEN_NAME");
fs.MatchingTweetReceived += (sender, args) =>
{
    Console.WriteLine(args.Tweet.Text);
};
fs.StartStreamMatchingAnyCondition();
Hope this helps.
Linvi

Viewing all articles
Browse latest Browse all 4126

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>