How to get the UID of current user?

Feb 1, 2010 at 1:14 AM

I have spent all day digging through this site and the documentation and can not come up with a sime API call to get the UID of the curent facebook user. Every time I find something that might be usefull in the documentation there is absolutly no userfull info about that namespace or class and all the code I fine on the discussions call api.uid which apparently does not exist version 3.1 of the toolkit. I have even gone through the code for the iframe example but the loginctron sample will not open cuase it has a system.runtime.interopservieces.comexeption and the other iframe exapmple does not seem to get the current uid anywhere.

Can anyone tell me how, in C#, to get the UID of the current Facebook user so I can use it to make other REST API calls?

Feb 1, 2010 at 6:50 AM

if you use site.master file, below script can get user's id.

Master.Api.Users.GetInfo().uid

Feb 2, 2010 at 12:11 AM
Edited Feb 2, 2010 at 12:12 AM
juxj wrote:

if you use site.master file, below script can get user's id.

Master.Api.Users.GetInfo().uid

 See this is what I am talking about. What site.master? When I call Master there is no API subset of it. And the documentation does not talk about any of this. There HAS to be some better documentation made for this app. Is this truly supported by Microsoft? I find it hard to imaged Microsoft would leave it this undocumented.

Feb 2, 2010 at 12:54 AM
Edited Feb 2, 2010 at 1:10 AM

I found it available here:

new Facebook.Session.ConnectSession(appKey, appSecret).UserId

When juxj is talking about Master he's not talking about a namespace in the toolkit, he's simply meaning a Master page file that's part of ASP.NET. If you look at the sample applications you can download they have the master page class extending Facebook.Web.CanvasFBMLMasterPage. So they've just created a public property on the Master page which is basically this:

public Facebook.Rest.Api Api { get { return new Facebook.Rest.Api(new Facebook.Session.ConnectSession(appKey, appSecret)); } }

Of course to access that property of Master you then need to set MasterType on all the pages that use the Master page.

Feb 2, 2010 at 1:35 AM
mcm_ham wrote:

I found it available here:

new Facebook.Session.ConnectSession(appKey, appSecret).UserId

When juxj is talking about Master he's not talking about a namespace in the toolkit, he's simply meaning a Master page file that's part of ASP.NET. If you look at the sample applications you can download they have the master page class extending Facebook.Web.CanvasFBMLMasterPage. So they've just created a public property on the Master page which is basically this:

public Facebook.Rest.Api Api { get { return new Facebook.Rest.Api(new Facebook.Session.ConnectSession(appKey, appSecret)); } }

Of course to access that property of Master you then need to set MasterType on all the pages that use the Master page.

the new Facebook.Session.ConnectSession(appKey, appSecret).UserId looks valid. About to go to sleep and head to work so no time tonight to test it but doing that line showed up.

All this is being done in Master file in ASP.Net and I am building it under a class that inherits the canvasIframemasterpage but was not working. I will play with that a bit more tomorrow too. Thanks!