简体   繁体   中英

Javascript Facebook SDK Syntax

I am using the Facebook javascript SDK to allow users of my webpage to update their status. I am getting a "Uncaught SyntaxError: Unexpected token ," in my login code for my permissions:

FB.login(function(response) 
{
    if (response.authResponse) 
    {
        alert('Logged in and accepted permissions!');
    }
}, {scope:'publish_stream', 'offline_access', 'manage_pages'});

Any ideas why that would be? I am pretty sure the syntax is correct.

You are writing permissions in wrong way,

Use this,

FB.login(function(response) 
{
    if (response.authResponse) 
    {
        alert('Logged in and accepted permissions!');
    }
}, {scope:'publish_stream, offline_access,manage_pages'});

Reference: http://developers.facebook.com/docs/reference/javascript/FB.login/

This is not a valid JS dictionary literal:

{scope:'publish_stream', 'offline_access', 'manage_pages'}

If you want those three items as a list under the key scope , enclose them in [] :

{scope: ['publish_stream', 'offline_access', 'manage_pages']}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM