Twitterizer - Search API Example

4.8k views Asked by At

Can someone please write up a quick example code on how to search the public twitter timeline for a specific hashtag or keyword or mention using the Twitterizer framework.

Thanks

2

There are 2 answers

0
Ricky Smith On BEST ANSWER

You should use the search API to search for a specific word or phrase.

In Twitterizer, it would look like:

TwitterResponse<TwitterSearchResultCollection> result = TwitterSearch.Search("#hashtag");
2
ThdK On

I'm using this now:

OAuthTokenResponse accessTokenResponse = OAuthUtility.GetAccessToken(consumerKey, consumerSecret, Request.QueryString["oauth_token"],Request.QueryString["oauth_verifier"]);

OAuthTokens tokens = new OAuthTokens();
            tokens.AccessToken = accessTokenResponse.Token;
            tokens.AccessTokenSecret = accessTokenResponse.TokenSecret;
            tokens.ConsumerKey = consumerKey;
            tokens.ConsumerSecret = consumerSecret;


            TwitterResponse<TwitterSearchResultCollection> tr = TwitterSearch.Search("your query");

        TwitterSearchResultCollection results= tr.ResponseObject;
        List<TwitterSearchResult> resultList= results.ToList();

I hope this can still help someone.