开发者

Help with facebook connect on a PHP site

开发者 https://www.devze.com 2022-12-15 02:06 出处:网络
I have about 90% of the PHP code done for a really nice facebook connect integration with my social networ开发者_运维知识库k but I am having 1 huge problem.

I have about 90% of the PHP code done for a really nice facebook connect integration with my social networ开发者_运维知识库k 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


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"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">

  • 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消