Skip to content

Instantly share code, notes, and snippets.

@webmonger
Created February 1, 2013 09:54
Show Gist options
  • Save webmonger/4690423 to your computer and use it in GitHub Desktop.
Save webmonger/4690423 to your computer and use it in GitHub Desktop.
.net Razor helper to be used with LinqToTwitter http://linqtotwitter.codeplex.com/ put the 4 oAuth keys for Single User Auth in your web.config and you've done you recieve a List<Status>
public static IList<Status> GetTwitterFeed(string screenName)
{
var auth = new SingleUserAuthorizer()
{
Credentials = new InMemoryCredentials
{
ConsumerKey =
ConfigurationManager.AppSettings["twitterConsumerKey"],
ConsumerSecret =
ConfigurationManager.AppSettings["twitterConsumerSecret"],
OAuthToken = ConfigurationManager.AppSettings["twitterOAuthToken"],
AccessToken =
ConfigurationManager.AppSettings["twitterAccessToken"]
}
};
List<Status> tweets;
using (
var twitterCtx = new TwitterContext(auth, "https://api.twitter.com/1/", "https://search.twitter.com/"))
{
//Log
twitterCtx.Log = Console.Out;
var publicTweets = from tweet in twitterCtx.Status
where tweet.Type == StatusType.User
&& tweet.ScreenName == screenName
select tweet;
tweets = publicTweets.ToList();
}
return tweets;
}
List<Status> tweets = GetTwitterFeed("billywizz")
@dreamguts
Copy link

Hey I think in your call example in gistfile2.text it should be IList not List?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment