使用Feed自动在用户墙上发布

时间:2013-09-14 07:43:54

标签: facebook-graph-api

我正在使用Facebook Feed在用户墙上发布而不显示供稿对话框,它按预期在登录用户的墙上发布。 但是如果用户没有授权应用程序,它没有发布在墙上,我想显示Dialog提示验证用户是否未验证应用程序,我使用FB.getLoginStatus(),但它返回连接状态,并且从文档我已经读过FB.getLoginStatus将返回连接,如果,请参阅Here

the user is logged into Facebook and has authenticated your application

这就是我使用FB.getLoginStatus()

的方式
 FB.getLoginStatus(function (response) {
                        if (response.status === 'connected') {
                            alert("connt");
                            // the user is logged in and has authenticated your
                            // app, and response.authResponse supplies
                            // the user's ID, a valid access token, a signed
                            // request, and the time the access token 
                            // and signed request each expire
                            var uid = response.authResponse.userID;
                            var accessToken = response.authResponse.accessToken;
                        } else if (response.status === 'not_authorized') {
                            alert("not");
                            // the user is logged in to Facebook, 
                            // but has not authenticated your app
                        } else {
                            alert("aa");
                            // the user isn't logged in to Facebook.
                        }
                    });

这是我发布墙的代码

 FB.api('/me/feed', 'post', { link: mywebsitelink, picture: mypicture, message: message }, function (response) {
                        if (!response || response.error) {
                            alert(response.error.message);
                        } else {
                            //  alert('Post ID: ' + response.id);
                        }
                    });

显示错误消息,即使FB.getLoginStatus显示已连接。

(#200) The user hasn't authorized the application to perform this action

1 个答案:

答案 0 :(得分:1)

用户需要接受扩展权限()才能在墙上发布。当用户接受该应用时,请务必在范围中包含“publish_stream”权限。

FB.login(function(response) {
// do you thing
}, {scope: 'publish_stream'});

FB.getLoginStatus()仅告诉您是否接受了应用,而不是是否也接受了任何扩展权限。