I'm using TweetSharp for C#, and I'm successfully able to publish tweets to twitter via this.
However, I'm trying to read the most recent tweets from the account's timeline, but I keep getting null back every time I try to get the data. The following code returns null
string consumerKey = <consumerKey>;
string consumerSecret = <consumerSecret>;
TwitterService service = new TwitterService(consumerKey, consumerSecret);
service.AuthenticateWith(consumerKey, consumerSecret);
var options = new ListTweetsOnUserTimelineOptions()
{
ScreenName = screenName,
SinceId = 0,
Count = 5
};
var currentTweets = service.ListTweetsOnUserTimeline(options);
I've tried using UserId
instead of ScreenName
, but I still get null
as a result fir currentTweets
. All the examples I can find are pointing to this method, but it doesn't work.
Any Ideas?
I think your problem is the AuthenticateWith call. You appear to be passing the consumer token and secret again, but the AuthenticateWith overload that takes only two arguments expects a user token and secret. I suspect you are therefore getting an unauthorised response (not sure why you don't get an error).
I would suggest either removing the AuthenticateWith call (you've already provided the consumer token in the constructor), or changing it so you pass details for a valid user token instead of the consumer one.
You could also check the Response property on the twitter service after your call completes, and inspect the http status code/reason phrase/content etc. to see if that gives you more detail about what is going wrong.