IsConnected is always false for my app

Jul 12, 2010 at 11:06 PM
Edited Jul 12, 2010 at 11:09 PM

Here's the issue I'm facing.

When I run Connect example included in the download, everything runs nice and well. I can log in and out and ConnectSession's IsConnected() returns "true" when I'm logged in and "false" when not.

 

However, when I add facebook.dll to my own sample web app and use my FB Test App's appKey and appSecret, IsConnected() is ALWAYS false, even when I'm logged in.

FB Test App settings:

- NOT in test mode

- Connect url is set to "http://localhost:5000/" which is my local dev environment

- All other fields in Connect tab are left blank (and the rest are default)

 

Web page code:

 

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!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">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <div id="fb-root"></div>
        <fb:login-button size="small" autologoutlink="true"></fb:login-button>            
        
        <script src="http://connect.facebook.net/en_US/all.js" type="text/javascript"></script>
        <script type="text/javascript">
          FB.init({appId: '<%=appID %>', status: true, cookie: true, xfbml: true});
          FB.Event.subscribe('auth.sessionChange', function(response) {
            if (response.session) {
              // A user has logged in, and a new cookie has been saved
            } else {
              // The user has logged out, and the cookie has been cleared
           }
          });
        </script>
    </div>
    </form>
</body>
</html>

 

Code behind:

 

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class _Default : System.Web.UI.Page 
{
    protected string appKey = "XXX";
    protected string appSecret = "XXX";
    protected string appID = "XXX";

    protected void Page_Load(object sender, EventArgs e)
    {
        Facebook.Session.ConnectSession conSes = new Facebook.Session.ConnectSession(appKey, appSecret);

        if (conSes.IsConnected())
        {
            System.Diagnostics.Debug.WriteLine("Connected!");
        }
        else
        {
            System.Diagnostics.Debug.WriteLine("Disconnected!");
        }
    }
}

 

Are there any parameters that I'm missing? Perhaps some settings in the FB test app? Thanks!

Jul 14, 2010 at 9:42 PM
Edited Jul 15, 2010 at 4:39 AM
I think you have to include: script type="text/javascript" src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php"></script instead of all.js, and call init like: FB.init("appid", "xd_receiver.htm"); all.js sets different cookies which aren't compatible with the toolkit.. Hope this helps!
Jul 15, 2010 at 4:14 AM
yes... something like this..

<script type="text/javascript">FB.init("[AppKey]","../xd_receiver.htm", { "reloadIfSessionStateChanged": true });</script>

On Thu, Jul 15, 2010 at 3:12 AM, Hiawatha <notifications@codeplex.com> wrote:

From: Hiawatha

I think you have to include: instead of all.js, and call init like: FB.init("appid", "xd_receiver.htm"); all.js sets different cookies which aren't compatible with the toolkit.. Hope this helps!

Read the full discussion online.

To add a post to this discussion, reply to this email (FacebookToolkit@discussions.codeplex.com)

To start a new discussion for this project, email FacebookToolkit@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com




--
Cheers,
Gopi Krishna. L


"I hate quotations. Tell me what you know."
                                   -Ralph Waldo Emerson