问题
How to get Face Book Current UserId . I would like to avoid asking for permissions since my users are just browsing and i only want to see if they have done this before.
回答1:
using Facebook c# sdk:
string signedRequest = Request.Form["signed_request"];
var DecodedSignedRequest = FacebookSignedRequest.Parse(Facebook.Web.FacebookWebContext.Current.Settings.AppSecret, signedRequest);
dynamic SignedRequestData = DecodedSignedRequest.Data;
accessToken = (String)SignedRequestData.oauth_token;
var app = new FacebookWebClient();
var me = (IDictionary<string, object>)app.Get("me");
firstName = (string)me["name"];
U_Id = (string)me["id"];
回答2:
As far as i know i don't think there is a way to get the UserId of the current user without asking for permissions.
If you look at the guide for signed request parameter, it does not return the userid until the user has allowed your application basic access.
来源:https://stackoverflow.com/questions/5240935/what-is-the-best-way-to-get-the-userid-of-the-current-user