Hello,
I'm trying to show the mentions of a user using the Timelines. I understand that this require a LoggedUser to work properly. I have been trying to set a loggedUser, however I keep getting the error "NullReferenceException was unhandled by user code". Can you guide me to find what is not working correctly?
Thanks.
The code is the following, implemented in an ASP button:
//https://github.com/linvi/tweetinvi/wiki/Timelines
//I had set the keys and token with the default ones given by Twitter in apps.twitter.com
int i = 1; //As a counter for all the mentions
var userCredentials = TwitterCredentials.CreateCredentials(
accessToken,
accessSecret,
consumerKey,
consumerSecret
);
//Here I get the error
var user = Tweetinvi.User.GetLoggedUser(userCredentials);
//var mentionsTimelineParameters = new MentionsTimelineParameters();
//var tweets = Timeline.GetMentionsTimeline(mentionsTimelineParameters);
var tweets = user.GetHomeTimeline();
foreach (ITweet mention in tweets)
{
TxtLog.Text += "**********Mention #" + i + "***********";
TxtLog.Text += "Message: " + mention.Text;
TxtLog.Text += "************************************";
i++;
}
I also tried without the loggedUser with:
var tweets = user.GetHomeTimeline();
However, the variable results in null.
And thank you very much for the quickresponses and for making this library, makes coding with Twitter more easy, understandable and fun.
Comments: duplicate
I'm trying to show the mentions of a user using the Timelines. I understand that this require a LoggedUser to work properly. I have been trying to set a loggedUser, however I keep getting the error "NullReferenceException was unhandled by user code". Can you guide me to find what is not working correctly?
Thanks.
The code is the following, implemented in an ASP button:
//https://github.com/linvi/tweetinvi/wiki/Timelines
//I had set the keys and token with the default ones given by Twitter in apps.twitter.com
int i = 1; //As a counter for all the mentions
var userCredentials = TwitterCredentials.CreateCredentials(
accessToken,
accessSecret,
consumerKey,
consumerSecret
);
//Here I get the error
var user = Tweetinvi.User.GetLoggedUser(userCredentials);
//var mentionsTimelineParameters = new MentionsTimelineParameters();
//var tweets = Timeline.GetMentionsTimeline(mentionsTimelineParameters);
var tweets = user.GetHomeTimeline();
foreach (ITweet mention in tweets)
{
TxtLog.Text += "**********Mention #" + i + "***********";
TxtLog.Text += "Message: " + mention.Text;
TxtLog.Text += "************************************";
i++;
}
I also tried without the loggedUser with:
var tweets = user.GetHomeTimeline();
However, the variable results in null.
And thank you very much for the quickresponses and for making this library, makes coding with Twitter more easy, understandable and fun.
Comments: duplicate