East of Nowhere
East of Nowhere

Reputation: 1396

window.fbAsyncInit / FB.init does not appear to be running

I am just getting started with the Facebook JavaScript SDK, all I want to do is enable users to log in to my web site with their FB account. First I put in the <div class="fb-login-button">Login with Facebook</div> and the boilerplate just like it says in the Facebook for Websites documentation at developers.facebook.com/docs/guides/web/#login

I click the FB login button, get the popup, click Allow...and nothing happens. I can't find any cookie like fbsr_APPID anywhere (e.g. Request.Cookies("fbsr_MYAPPID") turns up nothing) and the page didn't redirect to the Site URL I specified in the App's settings. I put some more JavaScript in to debug, and literally get nothing.

window.fbAsyncInit = function () {
    FB.init(
{
    appId: 'MYAPPID',
    channelUrl: http://bla,
    status: true,
    cookie: true,
    xfbml: true,
    oauth: true
});
    // Additional initialization code here
    alert("Please just prove this init code is running at all!!!!");

    FB.Event.subscribe('auth.login', function (response) {
        alert('Logged in: ' + response);
    }
    );

    FB.getLoginStatus(function (response) {
        alert('Check login: ' + response);
        if (response.authResponse) {
            var access_token = response.authResponse.accessToken;
            alert('Access token yay! ' + access_token);
        }
    });
};

None of the alerts show up or anything, leading me to think the whole script is failing to run.

I switched from that facebook button to the server-side authentication link described at developers.facebook.com/docs/authentication, and this time the redirect definitely happens and I get a code= in the query parameters, but I get the same [lack of] results running any FB.JavaScript methods, in Init or as an event handler. I still can't find a facebook cookie (tho maybe the server-side method never produces one?) but I figure with an Ajax call or something I'll be able to use the code to get the access_token (it'd be nice if FB's documentation gave some hints on how to use that code, but that's another issue).

Even if I ditch Facebook's JavaScript SDK as much as possible and rely on server-side scripting, I ought to be able to at least use FB.getLoginStatus. What could I be doing wrong?

Upvotes: 2

Views: 9217

Answers (1)

DMCS
DMCS

Reputation: 31870

I've narrowed your problem down to this line

channelUrl: http://bla,

It should read (of course with a real url to your channel file:

channelUrl: 'http://bla',

Upvotes: 4

Related Questions