tags:

views:

106

answers:

2

I have about 90% of the PHP code done for a really nice facebook connect integration with my social network but I am having 1 huge problem.

This code below is supposed to show a facebook connect button on the page but instead it show nothing at all.

<body onload="initFB();">

<fb:login-button length="long" background="light" size="medium"></fb:login-button>

<script type="text/javascript">
function fbConnect() {
    FB.init("", "/testing/facebook/xd_receiver.htm",{"reloadIfSessionStateChanged":true});
}
</script>

Further more if I hardcode a html popup for facebook connect to open then when it opens it up with the connection page and seems to work, everything works now except showing any of the facebook stuff on my page before or after loggin in with it

Any ideas what could be wrong? I think it has to do something with this xd_receiver.htm file, facebook ask you to put it on your page where you want to use facebook connect, it makes there javascript work and stuff, I have tried different file paths and such to see if that made a difference but it does not seem to help

+1  A: 

not sure, but if you're already logged in to fb, fb:login-button will not display anything. when autologoutlink is true, a logout link would be displayed instead in that case.

jspcal
It is not showing while logged in or out but thanks for the tip it will be useful when I get this working
jasondavis
+2  A: 

It's hard to tell what's going on from the code you posted. It looks like your <body> has an onload event of initFB(), but that function isn't present in the code you posted. Perhaps you mean to call fbConnect() there instead, which would call the FB.init() that you've specified?

With FB.init, you have to make sure that Facebook can access your xd_receiver.htm file. This is essential. Try accessing it manually by typing in the URL you have set up and make sure it serves properly. Double-check that the relative path is correct, and make sure that you have set up the Connect URL properly in the application settings control panel. Failure to serve this file to Facebook's servers will result in complete failure of any XFBML tags, and it sounds like that's probably the issue here judging by the error message you're getting.

EDIT

Some more points about XFBML:

  • In order for XFBML tags to work, you must specify xmlns:fb="http://www.facebook.com/2008/fbml" as an attribute in your <html> tag. Example:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"&gt;

  • You need to use the RequireFeatures call of the Facebook library to load the XFBML parser

  • You need to include the FeatureLoader.js library.

I'd suggest taking a walkthrough of the XFBML setup docs which details all of this, and make sure you've got all those requirements. From the code you've posted, it doesn't look like a couple of those things are there.

zombat
I think you are right about that file affecting it, I am even closer now though, facebook actually authorizes my site now and returns the facebook userid number in my case 501228771 back to my site when it is a successful login but it still will not show any facebook buttons
jasondavis
@jasondavis - I edited my answer and added a few more things you might want to check.
zombat
I am not sure exactly what the cause was (it could even be something to do with DNS records if that affect this even, I just re-routed a domain right before messing with this) Anyways I have it working, thanks for the tips
jasondavis