(Facebook C#SDK)FacebookWebContext.Current.IsAuthenticated总是返回false

时间:2011-08-04 20:50:07

标签: asp.net-mvc asp.net-mvc-3 facebook-c#-sdk

大家好我使用facebook c#sdk 5.0.50来获取网络应用程序中的Facebook帐户的电子邮件和名称,但FacebookWebContext.Current.IsAuthenticated始终返回false,fbWebContext.UserId始终为0(零)如果我登录Facebook。

我已经使用AppId和AppSecret配置了我的web.config。我还将Facebook.dll和Facebook.Web.dll复制到我的Bin文件夹中。我使用Facebook Javascript SDK来做日志记录部分。有什么东西我不见了吗?

这是我的代码

记录部分:

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' });

在Im后面的代码中使用以下代码:

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 lastName 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

我可以使用Facebook Javascript SDK显示信息,但我需要在服务器中执行此操作,因为在我获得用户后我需要处理它以查看他是否在我们的数据库中

请帮忙 提前致谢

1 个答案:

答案 0 :(得分:1)

看起来这是框架的错误(请参阅http://facebooksdk.codeplex.com/workitem/5893)您应该获得最新版本,修复程序就在其中。