Processing
 

How to do a twitter search using linq to twitter v.4 in c#

24/08/2016 10:35#1

Decoder94

Member

Joined at: 4 months ago

Post: 1

Thank: 0

Thanked: 0

I would like to do a search using linq to twitter v.4. the query that I have managed to accomplish so far gets the user tweets.

Is there a way to search the same way as you would in the twitter search box?

e.g. when I type music in the search box in the browser it shows all the relevant tweets.

I found this code online but am getting the error message 'StatusType'does not contain a definition for search.

var statusTweets = from tweet in twitterContext.Search                         where tweet.Type == StatusType.Search &&                         tweet.Query =="twitter"&&                         tweet.Count == 2 &&                         tweet.IncludeEntities == true                         select tweet; 
24/08/2016 16:49Top#2

Joe Mayo

Member

Joined at: 10 months ago

Post: 156

Thank: 0

Thanked: 0

LINQ to Twitter is async, so the code you posted is incomplete. Here's how that would work:

var statusTweets =      await     (from tweet in twitterContext.Search      where tweet.Type == SearchType.Search &&      tweet.Query =="MammothGraphics"&&      tweet.Count == 2 &&      tweet.IncludeEntities == true      select tweet)     .ToListAsync(); 

Notice the differences are await and ToListAsync(). If you are having trouble with async code, do a search for 'C# async' and you will find a lot of material. Stephen Cleary's Blog is also a good async resource.

There's documentation on the LINQ to Twitter wiki on Searching Twitter.

The Samples folder also has demos on how to use LINQ to Twitter. The Console Samples are more comprehensive and other samples are single demos of a few commands and queries so you can get a feeling for how LINQ to Twitter works with those technologies.

The part of your question about "Like the Twitter Search Box" is very general and unrelated to LINQ to Twitter and you might want to ask separate, more targeted questions about that. Please review the Stack Overflow Help section on Asking a Question to help you fine tune your question for the best results.

Similar articles

How do twitter giveaways work?

8 months ago - Reply: 2 - Views: 126

How may I get genuine followers on Twitter?

3 years ago - Reply: 33 - Views: 1,828

Login to Twitter sometime fail

6 months ago - Reply: 1 - Views: 23

Twitter doesn't accept PHP's cURL, but Linux'

1 year ago - Reply: 2 - Views: 90

Twitter OAuth on iOS

5 months ago - Reply: 1 - Views: 92

why am i getting an error on .verifyCredentials()

5 months ago - Reply: 1 - Views: 35

TwitteR setup_twitter_oauth() gives an error

5 months ago - Reply: 1 - Views: 29

Tweepy - Getting the author of a retweeted tweet

5 months ago - Reply: 0 - Views: 4

Retrieving data from twitter with JavaScript

5 months ago - Reply: 0 - Views: 2

Combined social media feed returning the wrong data

5 months ago - Reply: 0 - Views: 0

Django and Twitter request_token

5 months ago - Reply: 0 - Views: 0

Python HMAC hashed value encoding to base64

5 months ago - Reply: 1 - Views: 32

At the rate symbol in facebook

5 months ago - Reply: 0 - Views: 1

vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re vé máy bay vé máy bay giá rẻ ve may bay ve may bay gia re