Clicking on news feed item redirects to core postback url.

Nov 2, 2007 at 8:59 PM
First off -- great work on the toolkit, it is very impressive.

I am in the process of writing an application, and have the newsfeed item link in the form of:

http://apps.facebook.com/myapp/viewanswers.aspx?a=33

When I first log in and click the 'View Answers' link in my newsfeed, it redirects to the postback url for the application. Now, after my main application page has loaded, the news feed item works great. This leads me to believe that for some reason the session is not being fully set on my ViewAnswers page (which uses a Master Page) The master page is set up like this:

Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
loadFacebook()
End Sub
Public Sub loadFacebook()
_fbService.ApplicationKey = "949949949949949"
_fbService.Secret = "94994994994994994994"
_fbService.IsDesktopApplication = False

Dim sessionKey As String = TryCast(Session("facebooksessionkey"), String)
Dim userId As String = TryCast(Session("facebook_userId"), String)


Dim authToken As String = Request.QueryString("auth_token")

If Not Page.IsPostBack Then
If (Not String.IsNullOrEmpty(sessionKey)) Then
_fbService.SessionKey = sessionKey
_fbService.UserId = userId
ElseIf (Not String.IsNullOrEmpty(authToken)) Then
_fbService.CreateSession(authToken)
Session("facebooksessionkey") = _fbService.SessionKey
Session("facebook_userId") = _fbService.UserId
Session("facebook_userName") = _fbService.GetUserInfo.Name
Session("facebooksessionexpires") = _fbService.SessionExpires
' Need to login
Else
Response.Redirect("http://www.facebook.com/login.php?api_key=" & _fbService.ApplicationKey & "&v=1.0")
End If
End If
End Sub
Protected Overrides Sub OnPreRender(ByVal e As EventArgs)
'Dirty hack for IE?
Response.AppendHeader("P3P", "CP=\""CAO PSA OUR\""")
MyBase.OnPreRender(e)
End Sub

Am I missing something completely obvious? Any thoughts?

Thanks again.

Joshua
Nov 3, 2007 at 5:18 AM
Disregard my above message, I grabbed your full source, and ended up using your Masterpage implementation. Much easier than doing all of the crazy session stuff in each page load.

The code in the Masterpage example needed to have Overloads added.

Protected Overloads Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
MyBase.Api = FACEBOOKAPIKEY
MyBase.Secret = FACEBOOK_SECRET
MyBase.Page_Init(sender, e)
End Sub

I zipped up the project with the VB.NET solution fully working -- should I send it to you, or what is the process for that?

Thanks again for your amazing trailblazing on this.

Thanks,
Joshua
Developer
Nov 5, 2007 at 2:26 PM
Are the Overloads the only thing you changed in the solution? If so, the easiest thing for me is probably just to type in the changes quick myself. If you have some other changes, though, try uploading your solution on the Upload Patch page (http://www.codeplex.com/FacebookToolkit/SourceControl/UploadPatch.aspx). I haven't really used that feature of Codeplex yet, but I'd like to start trying it out if you have some other changes. If you do decide to go that way, leave some comments there as well to let me know what else was changed. Thanks.