Can not see FB login page when code is on website

Oct 4, 2009 at 6:44 PM

Hello,

I have a simple example I got of the net that lets a user log into their fb account. I am able to run this in VS 2008 no problems. But when I move it to the web server I go to that page I get our default login page of the website. It will not show the fb page.

Here is the code I am using.

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="FBTest.aspx.cs" Inherits="Test_FBTest" %>

<!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>My KPW Facebook Test Page!</title>
</head>
<body>
    <script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php" type="text/javascript"></script>
    <form id="form1" runat="server">
    <div>
        <fb:login-button length="medium" onlogin="window.close()"> </fb:login-button>
        <br />
        <fb:prompt-permission perms="read_stream,publish_stream" > Grant permission for status updates </fb:prompt-permission>
        <br />  
        <a href="#" onclick="FB.Connect.showPermissionDialog('status_update,read_stream,publish_stream', function(x){alert(x);}, false,null);">Grant permissions</a>
        <br />  
        <br />
        Name captured from Facebook Connect:  
        <asp:label id="lblName" runat="server" text="Not authenticated."></asp:label>  
    </div>  

    </form>
        <script type="text/javascript">  
        FB.init("1b1d7babec6c92957752f64426906a52", "xd_receiver.htm");  
    </script>
</body>
</html>

 

using System;
using System.Collections;
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;
using facebook;
using facebook.web;
using Kpw.Cms.Adaptor.Facebook;

public partial class Test_FBTest : System.Web.UI.Page
{


    protected void Page_Load(object sender, EventArgs e)
    {
        if (connectAuthentication.isConnected())
        {
            API api = new API();

            api.ApplicationKey = connectAuthentication.ApiKey;
            api.SessionKey = connectAuthentication.SessionKey;
            api.Secret = connectAuthentication.SecretKey;
            api.uid = connectAuthentication.UserID;

            //Display user data captured from the Facebook API.  

            facebook.Schema.user user = api.users.getInfo();
            string fullName = user.first_name + " " + user.last_name;

            lblName.Text = fullName;
        }
        else
        {
            //Facebook Connect not authenticated, proceed as usual.  
        }
    }
}

 

 

using System;
using System.Data;
using System.Configuration;
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;

namespace Kpw.Cms.Adaptor.Facebook
{
    /// <summary>
    /// Summary description for connectAuthentication
    /// </summary>
    public class connectAuthentication
    {
        public connectAuthentication()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        public static bool isConnected()  
        {  
            return (SessionKey != null && UserID != -1);  
        }  

        public static string ApiKey  
        {  
            get  
            {  
                return ConfigurationManager.AppSettings["APIKey"];  
            }   
        }  

        public static string SecretKey  
        {  
            get  
            {  
                return ConfigurationManager.AppSettings["Secret"];  
            }  
        }  

        public static string SessionKey  
        {  
            get  
            {  
                return GetFacebookCookie("session_key");  
            }  
        }  

        public static int UserID  
        {  
            get  
            {  
                int userID = -1;  
                int.TryParse(GetFacebookCookie("user"), out userID);  
                return userID;  
            }  
        }  

        private static string GetFacebookCookie(string cookieName)  
        {  
            string retString = null;  
            string fullCookie = ApiKey + "_" + cookieName;  

            if (HttpContext.Current.Request.Cookies[fullCookie] != null)  
            retString = HttpContext.Current.Request.Cookies[fullCookie].Value;  

            return retString;  
        }  
    }
}