What is the best way to get the UserId of the current user

谁说我不能喝 提交于 2019-12-24 08:47:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!