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: ** Comment from web user: linvi **
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: ** Comment from web user: linvi **
:p
This things happen to all of us!
If you want to get all the tweets with a specific HashTag, you will have to use the Search Engine (https://github.com/linvi/tweetinvi/wiki/Searches#tweet-searches).
If you want to search tweets with a specific hashtag from a specific user you will have to filter down the Timeline manually.
I am now closing this issue.
Cheers,
Linvi