I'm using TweetSharp with a view to simply getting the most recent tweet sent by the given Twitter account and posting it to a label on a page of my site. However, Im either lacking in Googleskillz or the TweepSharp documentation is not amazing.
Ive started with the simplest and apparently most relevant code example from the Github readme:
// In v1.1, all API calls require authentication
var service = new TwitterService(_consumerKey, _consumerSecret);
service.AuthenticateWith(_accessToken, _accessTokenSecret);
var tweets = service.ListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions());
foreach (var tweet in tweets)
{
Console.WriteLine("{0} says '{1}'", tweet.User.ScreenName, tweet.Text);
}
Ive then adapted this to:
// In v1.1, all API calls require authentication
var service = new TwitterService(_consumerKey, _consumerSecret);
service.AuthenticateWith(_accessToken, _accessTokenSecret);
var tweets = service.ListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions());
if (tweets != null)
{
return tweets.First().Text;
}
This seems to display random tweets rather than the latest one post from the actual Twitter account. This led me to trying different options without any notable understanding of what I was doing.
// In v1.1, all API calls require authentication
var service = new TwitterService(_consumerKey, _consumerSecret);
service.AuthenticateWith(_accessToken, _accessTokenSecret);
var tmpTweets = service.GetTweet(new GetTweetOptions());
if (tmpTweets != null)
{
return tmpTweets.Text;
}
But this simply returns a null result set and hence no tweets.
Hopefully someone knows a bit about TweetSharp and can help me out.