Seemed to be working but all of the sudden it starting making my FireFox browser refresh indefinately. I noticed that clicking Log Out didn't log me out, and then the FB Connect button stopped responding. Now it just works when it decides to but most of the time it doesn't.

This is the error I see in the FireFox console:
FB.login() called before calling FB.init().

Not sure what's going on but seems very buggy.

#30 Picture 23.png30.96 KBsime
Members fund testing for the Drupal project. Drupal Association Learn more


millo_avissar’s picture

I have the same problem with "FB Connect button stopped responding"
having error: FB.login() called before calling FB.init()

but in my case, it doesn't do anything at all.

before, I was using 6.x-3.x-dev (jun 2010), and had an infinite loop on login using fb-connect,
but it did connect the user, and sometimes I could escape that loop clicking on a link in the page.

Then, I upgraded to the latest version dated 2010-Oct-05,

Now, there is an even bigger problem I can not login at all.

another error that I now see is when entering any page:
FB.getLoginStatus() called before calling FB.init()

so I suspect there is some problem calling for FB.init()

Dave Cohen’s picture

I've never seen this problem. How do I reproduce it?

Can you make the same thing happen on

millo_avissar’s picture

hi Dave
just visited and logged in using fbconnect,
tried to logout but it keeps me connected.
anyway, it looks different since the page refresh and there are no js errors

millo_avissar’s picture

Priority: Normal » Major
Dave Cohen’s picture

Can you get a stack trace or line of code where the error is happening? I have nothing to add without additional info.

jjjames’s picture

It's hard to reproduce because it just seems to have a mind of it's own. Sometimes the page will refresh indefinately, and sometimes the FBConnect buttons never even shows up, and when it does, clicking it does nothing. One thing for sure, is that I can never get the facebook login window to pop up anymore.

Going to, and the page refreshed a couple times and I was seeing the FBConnect button, then after a couple refreshes (it kept refreshing automatically) I saw my picture and my name saying I'm connected. I try to click Log Out on and it won't let me log out. I logged out of facebook and then saw the fbconnect button again.

So a few problems... this shows up in firefox console when trying fbconnect on my site:
FB.login() called before calling FB.init()

and on i cannot log out. that can be dangerous.


Dave Cohen’s picture

What browser are you using when you can't log out? Do you have any special cookie privacy settings?

millo_avissar’s picture

when testing it on
I used both firefox and chrome and had the same behavior:
login works fine, I can see my fb-image
logout does not log me out, I still see my fb-image
only after logout from facebook I see the connect-with-facebook button

Dave Cohen’s picture

Mysterious. Works when I try it. Are you clicking the 'log out' link on the left side of the page?

Do you see any errors in firebug console or chrome's console?

millo_avissar’s picture

went again to
automatically was logged in
having many of these in the firebug profile:
The 'charCode' property of a keyup event should not be used. The value is meaningless.

then tried to logout using the logout link in the upper-left "my account" block
page refreshes, but stays connected, having (in the firebug profile) 7 rows of:
The 'charCode' property of a keyup event should not be used. The value is meaningless.

Dave Cohen’s picture

millo_avissar and jjjames, please test this patch, which I hope resolves the logout issue:

I don't think the javascript warnings are related. I still haven't reproduced any of the warnings described in this thread. Can you give more details how to reproduce?

millo_avissar’s picture

patch didn't work

pcambra’s picture

Version: 6.x-3.0-beta1 » 6.x-3.0-beta3

I'm getting also this error in Firefox and Chrome in the console:

FB.login() called before calling FB.init().

pcambra’s picture

Ok, more information, I think that this module is crashing with fb_social (I don't know if is a known problem).

Here is what I think is happening
fb_social calls to FB.init in a function called fb_social_footer which I suppose is placed somewhere at the end of the page, so when drupal for facebook make its calls, this problem manifests.
If I comment the line that outputs this FB.init call both modules work

pcambra’s picture

Seems like the problem is either from fb_connect or a communication between projects, see #811856: Does not work when Drupal for Facebook module is enabled and #852582: Integrate with another fb* modules

Dave Cohen’s picture

So, does everyone on this thread have both fb.module and fb_social.module enabled?

jjjames’s picture

I've got fb social enabled. Interesting, I'll try to disable and see what happens.

alexrayu’s picture

Confirmed. This is an interaction issue. When other FB modules, like FBSocial is installed, this error takes place.

anon’s picture

I had the exact same problem using fbconnect and fb_social thoghter.

But in my case, the solution was to insert the same App-key in both modules app-key fields.

Hops this helps.

drupalam’s picture

I am having this issue, but I took fb_social off a while back. The directory no longer even exists.

thijsvdanker’s picture

Appears that FB.init() needs either a appID or an apikey, I mitigated the error by providing my apikey to the settings.php (see README.txt)

Dave Cohen’s picture

Category: bug » support

I'm considering this not a bug, but I'd be interested if anyone posts a patch that helps work around this. I imagine a few lines of code in fb_social could make it let modules/fb do the app initializing.

kshankin’s picture

When you applied the API Key, did you do that to the facebook connect or fb_social module?

iknowbryan’s picture

I was having the same issue (FB connect button was not doing anything when clicked)
I added my apikey to the settings.php file as documented in the README, cleared my cache... and it now works!

//// Code to add to settings.php:

* Drupal for Facebook settings.

if (!is_array($conf))
$conf = array();

$conf['fb_verbose'] = TRUE; // debug output
//$conf['fb_verbose'] = 'extreme'; // for verbosity fetishists.

// More efficient connect session discovery.
// Required if supporting one connect app and different canvas apps.
//$conf['fb_apikey'] = '123.....XYZ'; // Your connect app's apikey goes here.

// Enable URL rewriting (for canvas page apps).
include "sites/all/modules/fb/";
include "sites/all/modules/fb/";

// end of settings.php

Hope this helps

Dave Cohen’s picture

Version: 6.x-3.0-beta3 » 6.x-3.x-dev

In another thread, there was a race condition which could cause the login before init error to appear, but only sometimes. I recommend anyone experiencing the problem upgrade to the latest and let me know if that makes the error go away. Thanks.

Thanks, be_design for the tip about the apikey.

JoshuaBud’s picture

I have tried both the rc8 and latest dev version and I get this error for both logout and login.

Dave Cohen’s picture

Search your page source for any place where facebook's javascript is included. Searching for "all.js" will normally find it. There should be only one place, in the page footer, referencing all.js. Is that the case?

JoshuaBud’s picture

Not sure where I came across the information that led me to add the following line of text to the page.tpl.php page but after removing it all finally worked and everything seems to be working fine now including Facebook Connect login, logout, etc.

<script src=""></script>

sime’s picture

Getting this error with the latest dev version. all.js is being included in the footer, and actually this error comes from all.js so it's definitely being included.

#28 is interesting. It sets the xfbml=1? I tried hard-coding this in fb.module but still get the same error.

This stackoverflow post suggests that .init() can fail silently with bad parameters. So the problem (for some of us) might be somewhere unexpected...

sime’s picture

30.96 KB

There are my settings via Firebug. Probably doesn't help.

Dave Cohen’s picture

The important thing is not just that all.js is included in the footer, but that it is onlyincluded there. That is no other module or snippet elsewhere is including it.

When that stackoverflow post talks about failing silently, I suspect there is actually an error in firebug or chrome's console. So those are good tools to check.

stereosteve’s picture

Version: 6.x-3.x-dev » 7.x-3.x-dev

I had this issue at first. This seemed to fix it:

1. Go to Administration >> Structure >> Facebook Apps
2. Edit app
3. Under Facebook Connect, click 'Primary'

This is pretty obvious, so I'm guessing this thread is related to a bigger issue, but just in case.

markflyer’s picture

Version: 7.x-3.x-dev » 6.x-2.0-rc3

I have a problem with fb connect. When I click on the buttons nothing happens. I would like to try your patch. However, when I place it in the settings.php in the site/default directory I get the code written all over the screen. Could you tell me what I am doing wrong. I have tried placing the patch in different places with the same results.
Thank you,

Dave Cohen’s picture

Version: 6.x-2.0-rc3 » 6.x-3.x-dev

This has been said elsewhere, but if you click and nothing happens, there's possibly a javascript error, and possibly your using IE without the xmlns:fb patch in your theme.

chadmkidner’s picture

I am having these same similar issues.. I get FB.getLoginStatus() called before calling FB.init(). error along with FB Connect functions not working, ALMOST all the time. The problem is not consistent at all, at first I tried to find consistency for when it either would or wouldn't give the error and the fact is there just isn't any.

I have been using Drupal for Facebook for awhile and through many updates and have not had problems with it before that couldn't be fixed fairly simply until this.. :/ I have tested the problem in Chrome, Firefox, and Opera to make sure it wasn't just my browser, no luck. Also double checked all the previous, what would seem to look like, simple solutions and nothing so far has fixed the problem. I am also running the same module on another website and it is still working just fine. The only difference, that may help diagnose the problem, is on the site that I am having the problem with has me auto signing in to the site somehow with my Facebook Connect whether or not I am actually signed into Facebook. I think this may be a result to checking the 'keep me signed in' checkbox when i first connected it.... Not sure but I know that on the site that is working in I am ONLY connected via FB when I am actually signed into facebook. It's like impossible for me to sign OUT on the nonworking site...

So I'm thinking that this Auto Sign In may have something to do with it... Any ideas on this?? Thanks! Oh and the URL is incase anyone wants to try and replicate the problem...

chadmkidner’s picture

One more thing to add to this, I just out of curiosity logged out of my facebook profile and refresher the website and now I'm in an endless loop of the site trying to log me in and failing... if that helps? While its doing it I was watching the console and same error primarily as before.. FB.getLoginStatus() called before calling FB.init().

chadmkidner’s picture

Alright so after much trail and error I kinda feel like dumb, as much as I didnt think I had this code placed anywhere else, I found <script src=""></script> embedded in a fb:like-box I had added some time ago for my Company Facebook Page. In case anyone is having a similar problem, heres the whole code snippet where I finally found the extra script embedded.

<div><script src=""></script><fb:like-box href="" width="240" colorscheme="dark" show_faces="true" stream="true" header="false"></fb:like-box></div>

I never seemed to have problems with this being there before but anyway removed the extra js script and everything looks like its working well again! I'll post if I notice anything I missed.

Dave Cohen’s picture

I'm not sure whether to resolve this issue or not. Here's how I understand it...

The most common cause of this problem is as described in comment #37. Facebook encourages you to copy and paste markup that includes a <script> tag. This causes problems if you are hosting an application.

Second cause is some other facebook-related module doing the same thing. That is, some other module's code includes facebook's script.

There was at some point a bug in modules/fb that caused this, but it is fixed.

thoughtcannon’s picture


manischewitzbacon’s picture

+1 to stereosteve and the checking "primary" on the settings of my app

it'd be cool if we could vote up solutions on issues a'la stack overflow, no?

hanoii’s picture


hanoii’s picture

I am struggling a lot with this. I am also facing this problem on chrome, but it's very odd. Can you try help out here with something.

I am using a bare fb module for now just to display one single like button, it should be barely straightforward but I can't seem to figure out what's happening. I am using rc13.

The site itself is, it's in Spanish, but just follow the first post and it should have a like button after the content.

It works on FF... but on chrome I see different behaviors. It doesn't seem to ever work anonymously. Logged in it's even more strange, it works intermittent. One refresh it works and one refresh it doesn't :s. Even more, on both anony and logged in, and both when it works and when it doesn't I see the

FB.getLoginStatus() called before calling FB.init().

on chrome's console.

I don't see it on and the like button works fine. I don't get it?

Is it mandatory to create a fb app or I can use a few of the social apps w/o? I understood you could just use it w/o any app.

Any help on this is extremely appreciated.

I started to think that the adsense block, which raises errors on chrome (known issue - was maybe affecting it somehow I removed it and it was the same. Even more, has the same adsense errors on chrome.

You might want to check, it's a copy of the site's HTML that I removed the adsense for now.

Dave Cohen’s picture

Is it mandatory to create a fb app or I can use a few of the social apps w/o?

In principal you do not need an app, but there is a bug. Please test the patch in #1160934: Like Button and other XFBML not working without application.

erikolson’s picture

I am having something like this problem.

Firefox and Chrome work OK.
IE 8 on 2 machines exhibit this issue:

Proceeding to as an existing user, and also as a new user causes the IE page to refresh over and over endlessly. Nothing can be seen in the canvas space during this process.

I was using a version which I installed in or around March 2011. I removed the module, copied RC13 onto the server, and re-enabled it, checked all of the settings - exactly the same behavior, FireFox, Chrome OK, IE refreshes over and over.

I overwrote modules/fb with the contents of 6-x-3-x-dev 2011-jun-03 and still the same thing, Firefox, Chrome OK, IE refreshes.

I'm scouring the known universe for clues ...

erikolson’s picture


Facebook Connect works in IE when using it from the actual website.

Looking at the browser history after a refresh incident in facebook shows

Dave Cohen’s picture

I am having something like this problem.

Doesn't sound the same to me.

Look for P3P in the README.txt (in fact, look at all the words in the README.txt) and also the troubleshooting page in the documentation. The infinite refreshes shouldn't happen, that may be a bug, but I think the p3p thing will work around it.

If still a problem, submit a new issue.

erikolson’s picture



bala.d’s picture

I'm using fbconnect module and fb_social module. I thought this might conflict each other. So I follwed the changes in settings.php.
Jus the app id is set there. remaining code jus commented out.
And now i get the modal box without any error.

Thanks to be_design.

Dave Cohen’s picture

fb_social user see also #1505274: conflict with modules/fb