I am using the jQuery library for authenticating the user, using this script:

<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
    // Initialize the library with the API key
    FB.init({ apiKey: 'SECRET_KEY' });

    // Fetch the status on load
    FB.getLoginStatus(handleSessionResponse);

    dojo.connect(dojo.byId('login'), 'click', function() {
        FB.login(handleSessionResponse);
    });

    dojo.connect(dojo.byId('logout'), 'click', function() {
        FB.logout(handleSessionResponse);
    });

    dojo.connect(dojo.byId('disconnect'), 'click', function() {
        FB.api({ method: 'Auth.revokeAuthorization' }, function(response) {
            clearDisplay();
        });
    });

It is showing

An error has occured please try again. followed by an OK button.

When I click that OK button it says:

Sorry, something went wrong. We're working on getting this fixed as soon as we can.

有帮助吗?

解决方案

From the documentation for the JavaScript SDK:

You can see that your secret key is not needed, as the JavaScript is available for anyone to read. Facebook's authentication uses the domain of your request to verify that it is, in fact, your application.

<div id="fb-root"></div>
<script>
    window.fbAsyncInit = function() {
        FB.init({
            appId      : 'YOUR_APP_ID', // App ID
            channelUrl : '//WWW.YOUR_DOMAIN.COM/channel.html', // Channel File
            status     : true, // check login status
            cookie     : true, // enable cookies to allow the server to access the session
            xfbml      : true  // parse XFBML
        });

        // Additional initialization code here
    };

    // Load the SDK Asynchronously
    (function(d){
        var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
        if (d.getElementById(id)) {return;}
        js = d.createElement('script'); js.id = id; js.async = true;
        js.src = "//connect.facebook.net/en_US/all.js";
        ref.parentNode.insertBefore(js, ref);
    }(document));
</script>

其他提示

This is wrong:

FB.init({ apiKey: 'SECRET_KEY' });

Not secret key, just the application id.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top