开发者

Facebook C# SDK for Facebook Connect

How can I use Facebook C# SDK for facebook connect using ASP.NET?

What I am trying to do is:

  1. Provide a "Login with Facebook" button.
  2. Once the user clicks on Login button, get the access token on server side and sign in to my website.

Most articles (I found through google or SO) said use Facebook Javascript SDK for Log in and Authentication and then get the Access token from cookies created on web browser.

What I did so far:

Used Facebook login button in .aspx page with the below code.

<fb:login-button onlogin="window.location.reload();" perms="offline_access">Login with Facebook</fb:login-button>

Problems I am having:

  1. When I click log in button on MY PAGE a window will pop up to log in to facebook. MY PAGE is supposed to reload when I login to facebook but it reloads even I click on Cancel button or close the pop up window. What I need is reloading MY PAGE only when I log in.

  2. From the above step: If I log in and MY PAGE reloads perfectly. In code behind (Page load event) I can see the cookie created and it has the information (access token) what I needed. And from here I want to use Facebook C# SDK to get user information. how to do ?

I used Facebook C# SDK 3 months ago for developing a canvas application in Facebook. The documentation and examples listed on Code开发者_如何转开发plex are for Apps on Facebook (correct me if I missed to see facebook connect examples). Also, there was a link to documentation which lists all the Facebook C# SDK classes but I could not see that now. Please provide me the link if you know.

Any help will be greatly appreciated. Thank you.


http://blog.prabir.me/post/Facebook-CSharp-SDK-Writing-your-First-Facebook-Application-v6.aspx

But there is one issue I am not using

parameters.response_type = "token"; 

Instead of that i have function to update Token

public static void UpdateToken()
        {
            var fb = new FacebookClient();

            dynamic result = fb.Get("oauth/access_token", new
            {
                client_id = AppId,
                client_secret = AppSecret,
                redirect_uri = Url,
                code = FacebookUtils.FacebookData.Code
            });
            FacebookData.AccessToken = result.access_token;
        }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜