简体   繁体   English

Javascript Facebook SDK语法

[英]Javascript Facebook SDK Syntax

I am using the Facebook javascript SDK to allow users of my webpage to update their status. 我正在使用Facebook javascript SDK来允许我的网页用户更新其状态。 I am getting a "Uncaught SyntaxError: Unexpected token ," in my login code for my permissions: 我在我的登录代码中获得了一个“Uncaught SyntaxError:Unexpected token”,我的权限是:

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/ 参考: http //developers.facebook.com/docs/reference/javascript/FB.login/

This is not a valid JS dictionary literal: 这不是有效的JS字典文字:

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

If you want those three items as a list under the key scope , enclose them in [] : 如果您希望这三个项目作为关键scope下的列表,请将它们包含在[]

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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