Quantcast
Channel: Tweetinvi a friendly Twitter C# library
Viewing all articles
Browse latest Browse all 4126

Commented Unassigned: GetLoggedUser returns null [2622]

$
0
0
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 really have to go to bed now as it is 3:08 am and I have to wake up in 5 hours :p

The code is correct and you definitely work.
I will try to get back to you as soon as I can. In the meantime could you try using the `TwitterCredentials.SetCredentials`.

I will get back to you hopefully tomorrow if I have some spare time.

Cheers,
Linvi


Viewing all articles
Browse latest Browse all 4126

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>