Reputation: 419
Im trying to get the Facebook users id saved in my database but I got this error:
System.NullReferenceException: Object reference not set to an instance of an object.
Im using Newtonsoft.Json.Linq and the method SelectToken
to get the "registration.id"
Here is the code:
string FB_ID= o.SelectToken("registration.id").ToString();
string FB_Firstname = o.SelectToken("registration.first_name").ToString();
string FB_Lastname = o.SelectToken("registration.last_name").ToString();
I can successfully get the Firstname and Lastname of the user but the string FB_ID gives me the Object reference not set to an instance of an object error.
Upvotes: 0
Views: 116
Reputation: 1494
I do not know which FB library you are using (Facebook C# SDK does not have a SelectToken method)... but Facebook uses "uid" instead of "id".
So... you might need to use:
string FB_ID= o.SelectToken("registration.uid").ToString();
Hope it helps.
Upvotes: 1