Facebook Get User ID From Application Tab
Facebook apps are allowed to have a tab that开发者_如何学Go a user can add to his profile's tabs if he wants.
How can I get the uid or otherwise identify the currently logged in user in order to customize the layout for him please?
Thank you.
As noted here:
Facebook does not pass back who the viewing user is when she first visits your tab. Facebook does send the profile owner's ID in the fb_sig_profile_user parameter, so you know whose profile to display content for.
Visitor id is passed as request parameter after a user interacts with your tab. I can't find exact parameter name as they removed a wiki page that used to contain a list of all passed parameters, but if you dump all your request vars you should be able to see it (but not during the first visit).
some sources to do it + you must have turned on all items on migration in app settings
http://nathrondevblog.blogspot.com/2010/09/how-to-get-user-id-in-profile-tab.html
Try out this one, If the user is logged in. You can directly get the user_id, session_key etc from the querystring.
long fbuid = long.Parse(Request.QueryString.Get("fb_sig_user"));
精彩评论