Ammar Khan
Ammar Khan

Reputation: 2585

How to get Mentions of other user using Linq To Twitter

I want to get mentions of a any user using linq to twitter api. I have a code which brings back the user time line, but I want to get only mentions of a user, one of the method that is Mention Timeline can only be used to get mentions for authenticatd user but I want to get for any user. How it is possible? Here is my code which return a user timeline, what modification require in it? Please help

 var mentions= await _twitterContext.Status
                     .Where(s => s.ScreenName== ScreenName && s.Type == StatusType.User && s.Count == 200)
                     .ToListAsync();

Upvotes: 0

Views: 306

Answers (1)

Joe Mayo
Joe Mayo

Reputation: 7513

The Twitter API doesn't expose an endpoint that allows you to get mentions for any user with a screen name. However, you can get the mentions if you are authorized by the user for whom you want to get mentions for. Here's an example:

        var tweets =
            await
            (from tweet in twitterCtx.Status
             where tweet.Type == StatusType.Mentions &&
                   tweet.ScreenName == "JoeMayo"
             select tweet)
            .ToListAsync();

        PrintTweetsResults(tweets);

The documentation for this is here:

http://linqtotwitter.codeplex.com/wikipage?title=Querying%20the%20Mentions%20Timeline&referringTitle=Making%20Status%20Queries%20and%20Calls

Upvotes: 1

Related Questions