Daniel
Daniel

Reputation: 11

How to get the Twitter Usertimeline with Tweetsharp

I try to get the last 20 statuses of the Usertimeline. So I search in the internet and get the follow code:

TwitterUser twitterUser = TwitterUser.Show("Username").ResponseObject;
if (twitterUser != null)
{
    UserTimelineOptions userTimelineOptions = new UserTimelineOptions();
    userTimelineOptions.UserId = twitterUser.Id;

    return TwitterTimeline.UserTimeline(userTimelineOptions).ResponseObject;
}
return null;

When I test it, I get the follow exception:

Unexpected token when deserializing object: StartObject. Line 1, position 1795.

I have no idea what's wrong so I hope you can help me!

Upvotes: 1

Views: 3729

Answers (2)

JP Hellemons
JP Hellemons

Reputation: 6057

Since Twitterizer is discontinued, I assumed that you moved to TweetSharp:

TwitterService service = new TwitterService("consumerKey", "consumerSecret");
service.AuthenticateWith("accessToken", "accessTokenSecret");
var options = new ListTweetsOnHomeTimelineOptions();
options.ExcludeReplies = true;
var tweets = service.ListTweetsOnHomeTimeline(options);

For Twitterizer:

UserTimelineOptions options = new UserTimelineOptions();
options.ScreenName = "Username";

var tweets = TwitterTimeline.UserTimeline(options).ResponseObject;

Twitterizer uses the 1.0 API and TweetSharp has the required oAuth for the 1.1 twitter API: https://dev.twitter.com/blog/changes-coming-to-twitter-api

Upvotes: 1

Asif Mushtaq
Asif Mushtaq

Reputation: 13150

Try this

var twitterService = new TwitterService("consumerKey", "consumerSecret");
twitterService.AuthenticateWith("token", "tokenSecret");
var tweets = twitterService.ListTweetsOnHomeTimeline();

Upvotes: 0

Related Questions