CanvasAuthorizer.Authorize()在facebook C#sdk 4.0.1中被破坏了吗?

时间:2013-02-08 18:14:42

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

我一直在Facebook的Canvas应用程序(ASP.NET Web窗体)中使用旧的Facebook C#SDK(版本4.0.1)。我在SDK中使用的唯一功能是授权用户并获取Facebook用户ID。该API适用于安装了canvas应用程序的用户,但不适用于新用户。

我有以下代码:

Dim lFacebookApp As FacebookApp()
Dim lCanvasAuthorizer As CanvasAuthorizer

Dim lFacebookSettings As New FacebookSettings()
Dim lCanvasSettings As New CanvasSettings()

lFacebookSettings.AppId = "XXXXXXXX"
lFacebookSettings.AppSecret = "XXXXXXXXXX"
lFacebookSettings.CookieSupport = True

lCanvasSettings.CanvasPageUrl = "Canvaspageurl"
lCanvasSettings.CanvasUrl = "canvasUrl"
lCanvasSettings.AuthorizeCancelUrl = New Uri("http://www.facebook.com")

lFacebookApp = New FacebookApp(lFacebookSettings)
lCanvasAuthorizer = New CanvasAuthorizer(FacebookApp, lCanvasSettings)
lCanvasAuthorizer.Perms = "user_about_me, publish_stream"

If (lCanvasAuthorizer.Authorize()) Then
 Dim info = lFacebookApp.Get("me")
 Dim userId = info.id
End If

这是如何工作的: 当新用户浏览到www.apps.facebook.com/<appname>时,lCanvasAuthorizer.Authorize()会自动打开“登录对话框”和“OAuth”对话框。

但是,现在它在Dim info = lFacebookApp.Get("me")

处抛出以下错误
(OAuthException) Error validating access token: The session is invalid because the user logged out.

lCanvasAuthorizer.Authorize()应该为用户打开oAuth对话框,但事实并非如此。旧的Facebook C#SDK坏了吗?

1 个答案:

答案 0 :(得分:1)

Facebook C#SDK版本4.0.1已弃用。使用latest version