Can't connect! PLEASE help!

Jan 5, 2011 at 3:57 PM
Edited Jan 5, 2011 at 3:58 PM

I'm tearing my hair out here - I just can't get a simple test to work at all! Can anyone point me in the right direction?

I'm using the Beta 3.1 version in Visual Studio 2010 with ASP.NET VB

 

My Master page:

 

<%@ Master Language="VB" CodeFile="canvasPage.master.vb" Inherits="FBTest.fbMaster" EnableViewState="true" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
<head runat="server">
    <title></title>
    <asp:ContentPlaceHolder id="head" runat="server">
    </asp:ContentPlaceHolder>
</head>
<body>    
    <form id="form1" runat="server">
    <div>
        
        <asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">        
        </asp:ContentPlaceHolder>
    </div>
    </form>
    

    <script type="text/javascript" src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US"></script>

    
    <script type="text/javascript">
        FB_RequireFeatures(["XFBML"], function() {
        FB.Facebook.init("<KEY>", "channel/xd_receiver.htm");
        });
    </script>

    
</body>
</html>

 

The Master page codebehind:

 

 

Imports System
Imports System.Collections
Imports System.Configuration
Imports System.Data
Imports System.Linq
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Xml.Linq
Imports Facebook
Imports Facebook.Web
Imports Facebook.Schema
Imports Facebook.Session
Imports Facebook.Rest

Namespace FBTest
    Partial Public Class fbMaster
        Inherits Facebook.Web.CanvasIFrameMasterPage

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            RequireLogin = True
        End Sub
    End Class

End Namespace

 

The aspx page:

 

 

<%@ Page Title="" Language="VB" MasterPageFile="~/canvasPage.master" AutoEventWireup="true" CodeFile="chilliandchoc.aspx.vb" Inherits="FBTest.chilliandchoc" EnableSessionState="True" %>
<%@ MasterType VirtualPath="~/canvasPage.master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<h1>Welcome</h1>
<p>You are <asp:Label ID="lblUsername" runat="server" Text="Not logged in!" /></p>
<asp:Button ID="btnSubmit" runat="server" Text="Send" />
</asp:Content>

 

And the code-behind:

 

Imports System
Imports System.Collections
Imports System.Configuration
Imports System.Data
Imports System.Linq
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.HtmlControls
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Xml.Linq


Namespace FBTest
    Partial Class chilliandchoc
        Inherits System.Web.UI.Page
        'Private connectSession As Facebook.Session.ConnectSession
        Private connectSession As Facebook.Session.FacebookSession
        Private thisAPI As Facebook.Rest.Api
        Dim myUser As Facebook.Schema.user


        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            
            connectSession = New Facebook.Session.IFrameCanvasSession(ConfigurationManager.AppSettings("ApiKey"), ConfigurationManager.AppSettings("Secret"))


            If Not Page.IsPostBack Then
                thisAPI = New Facebook.Rest.Api(connectSession)
                myUser = thisAPI.Users.GetInfo(thisAPI.Session.UserId)
                lblUsername.Text = myUser.name
            End If

        End Sub
    End Class

End Namespace

 


When I attempt to user the "myUser" object I'm getting the error "object reference not set to an instance of an object."

Trying to reference any session variables showed that the Facebook session variables weren't being populated..

Please - any ideas?? 

 

 

 

Jan 6, 2011 at 12:53 AM

The Facebook Toolkit is pretty much dead and hasn't been updated in over 6 months. I would recommend switching to the Facebook C# SDK.