开发者

(Facebook C# SDK) FacebookWebContext.Current.IsAuthenticated always return false

开发者 https://www.devze.com 2023-03-25 19:33 出处:网络
Hi guys im using the facebook c# sdk 5.0.50 to get the email and name of a facebook account in a web application but the FacebookWebContext.Current.IsAuthenticated always return false and the fbWebCon

Hi guys im using the facebook c# sdk 5.0.50 to get the email and name of a facebook account in a web application but the FacebookWebContext.Current.IsAuthenticated always return false and the fbWebContext.UserId is always 0 (zero) even if im logged in facebook.

I already configured my web.config with my AppId and my AppSecret. I also copied the Facebook.dll and the Facebook.Web.dll to my Bin folder. Im using the Facebook Javascript SDK to do the logging part. Is there something im missing?

Here is my code

The logging Part:

FB.login(function (response) {
    if (response.authResponse) {

        FB.api('/me', function (response) {
            console.log('Good to see you, ' + response.name + '.');                               
            window.location.reload();
        });
   } else {
        console.log('User cancelled login or did not fully authorize.');
   }
}, { scope: 'email,user_birthday' });

And in the code behind Im using the following code:

If fbWebContext.IsAuthenticated Then
   Dim fb = New FacebookWebClient(fbWebContext)

   Dim meInfo = CType(fb.Get("me"), Dictionary(Of String, Object))
   Dim firstName As String = meInfo("first_name")
   Dim last开发者_如何学CName As String = meInfo("last_name")
   Dim email As String = meInfo("email")

   Mensaje.Text = String.Concat("code: ", firstName)
Else
   Mensaje.Text = "not authorized - " & fbWebContext.Settings.AppId & " -" & fbWebContext.Settings.AppSecret
End If

I can display the info using the Facebook Javascript SDK but i need to do this in the server because after i get the user i need process it to see if he is in our database

Please some help Thanks in advance


Looks like it was a bug with the framework (see http://facebooksdk.codeplex.com/workitem/5893) You should get the latest version, the fix is in it.

0

精彩评论

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