Can someone take a look at my short javascript code and see why Facebook Connect is not working?
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.1.min.js"></script>
<script type="text/javascript">
function isLoggedIn(){
$('#fb_dash_anon').hi开发者_开发问答de();
$('#fb_dash_loggedin').show();
}
function isNotLoggedIn(){
$('#fb_dash_loggedin').hide();
$('#fb_dash_anon').show();
}
</script>
<script src="http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US" type="text/javascript"></script>
<script type="text/javascript">
FB.init("1bdcdc1f61590a4b9f63b7dcf07a4e42", '/xd_receiver.htm', {"ifUserConnected" : isLoggedIn, "ifUserNotConnected" : isNotLoggedIn});
</script>
<div id="fb_dash_loggedin" style="display:none;">
You are currently logged in.
</div>
<div id="fb_dash_anon" style="display:none;">
<fb:login-button onlogin="window.location = '/';">Connect</fb:login-button>
</div>
It's very simple. I followed all the instructions that they have. In fact, this works on my other site. I just copied and pasted it to this new site and it's not working.
I have xd_receiver.htm, and it's there correctly. My site is: http://174.143.207.170:8000/
Probably your App settings on facebook.com are not set up correctly. Check the settings and make sure it's pointing to your site url
1 facebook app can't point to multiple domains.
It's been many months since I messed with FaceBook Connect, but I remember a couple "gotchas" that you may want to look into...
(1) IIRC, you have to register your app with FaceBook and get some sort of API key; FaceBook matches the host & domain of the incoming request with what it expects them to be based on the registration. If you're using the same API key for both sites, it probably won't work.
(2) There was something tricky I had to do to get it to work with localhost, and you may need to do something similar for a site based on an IP (not a registered domain name). I think I had to edit my HOSTS file to tell my laptop that it was the domain I registered with FaceBook, but perhaps I'm not remembering this part precisely.
精彩评论