SetFBML and Invalid API Key

Aug 14, 2007 at 9:51 PM
I have code thats attempting to write what is in a text box to a user's profile. I'm getting an invalid api key exception. The segment of the code where this is happening is...

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim org As String
org = TextBox1.Text
+Me.FBService.SetFBML("Hello this is a test. The name of your input is " + org + "")+
End Sub

The rest of my code is just the authentication code from the 1.2 documentation and handling a button click...

Partial Public Class _Default
Inherits CanvasFBMLBasePage

Private Const FACEBOOKAPIKEY As String = "3d306ee5b60cd77e8c3e1becb6675b7a"
Private Const FACEBOOK_SECRET As String = "b7ab3bb6869787caefc02a107699f4d3"

Protected Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

End Sub

Private _fbService As Facebook.Components.FacebookService = New Facebook.Components.FacebookService()

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim org As String
org = TextBox1.Text
_fbService.SetFBML("Hello this is a test. The name of your input is " + org + "")
End Sub

Protected Shadows Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

' ApplicationKey and Secret are acquired when you sign up for
fbService.ApplicationKey = FACEBOOKAPI_KEY
fbService.Secret = FACEBOOKSECRET
_fbService.IsDesktopApplication = False

Dim sessionKey As String = TryCast(Session("Facebooksessionkey"), String)
Dim userId As String = TryCast(Session("Facebook_userId"), String)

' When the user uses the Facebook login page, the redirect back here will will have the auth_token in the query params
Dim authToken As String = Request.QueryString("auth_token")

' We have already established a session on behalf of this user
If (Not String.IsNullOrEmpty(sessionKey)) Then
_fbService.SessionKey = sessionKey
_fbService.UserId = userId
' This will be executed when Facebook login redirects to our page
ElseIf (Not String.IsNullOrEmpty(authToken)) Then
_fbService.CreateSession(authToken)
Session("Facebooksessionkey") = _fbService.SessionKey
Session("Facebook_userId") = _fbService.UserId
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

If (Not IsPostBack) Then
' Use the FacebookService Component to populate Friends

End If
End Sub
End Class


Is it possible that I'm not using setFBML correctly?
Aug 15, 2007 at 5:12 PM
Another potential issue is I didn't get rid of the default html code in default.aspx (thats the name of my file). I didn't know what parts to get rid of because when I got rid of all of it, I started getting errors when I added simple things like text boxes or labels.