ASP.NET website authentication with facebook

前端 未结 1 1510
无人及你
无人及你 2020-12-06 13:58

I\'ve seen a lot of documentation about integration between ASP .NET web sites and Facebook, but I haven\'t found a simple working example, even using Facebook C# SDK.

1条回答
  •  隐瞒了意图╮
    2020-12-06 14:42

    as you say using Facebook C# SDK, then here is path and some code for canvas application:

    1- Create your web application from visual studio
    2- install nuget and get by nuget Facebook C# SDK
    3- from https://developers.facebook.com/apps/ create and configure your app.
    4- Your web config for facebook integration :

    
      
        
    ...

    By using sdk, you can parse signed request or cookie written by facebook js sdk

    FacebookWebContext fbWebContext = new FacebookWebContext();
    //Check if user auhtenticated
    bool IsAuthenticated = fbWebContext.IsAuthenticated(); 
    

    Here you can have friend count by:

    FacebookWebClient fbWebClient = new FacebookWebClient();
    dynamic result = fbWebClient.Get("me/friends");
    var friends = result["data"];
    int frienCount = friends.Count;
    

    For the client side:

     
    
提交回复
热议问题