Facebook的C#SDK获取当前用户(Facebook C# SDK Get Current U

2019-06-23 12:14发布

I m working on a Facebook App. Not a website.

I am trying to use Facebook C# SDK and trying to get Current User and Query Current User info. How do i do that?

Also, When i try to use an app it s asking for Adding the app, requesting permission to access data, how do i do that also?

Is there a comprehensive examples of these things?

Answer 1:

如果你坚持使用.NET 3.5的工作,这将工作:

var facebookClient = new FacebookClient(FacebookAccessToken);
var me = facebookClient.Get("me") as JsonObject;
var uid = me["id"];


Answer 2:

您需要访问令牌。 一旦你的访问令牌做出请求me

var fb = new FacebookClient("access_token");
dynamic result = fb.Get("me", new [] { fields = "id" });
var userId = result.id;


文章来源: Facebook C# SDK Get Current User