Titanium中的Facebook publish_actions错误

时间:2014-08-26 03:45:43

标签: facebook facebook-graph-api titanium appcelerator publish-actions

我尝试在 Titanium 中使用 publish_actions 作为我的应用,但我得到" sdk facebook错误5" 。我看到Facebook最近更改了此权限,现在您必须提交应用程序,屏幕截图和其他内容以供审批。有一些文档可以将这个权限作为开发人员使用,比如scope属性,但我没有找到钛。我正在使用我的Facebook帐户,该帐户是应用程序的管理员。

此代码目前无效:

        fb.permissions = ['publish_actions'];  
        //I've also used fb.permissions = ['publish_stream'];  
        fb.authorize();

        // ...
        // ...

        // Now create the status message after you've confirmed that authorize() succeeded
        fb.requestWithGraphPath('me/feed', {message: "Trying out FB Graph API and it's fun!"}, 
                 "POST", function(e) {
            if (e.success) {
                alert("Success!  From FB: " + e.result);
            } else {
                if (e.error) {
                    alert(e.error);
                } else {
                    alert("Unkown result");
                }
            }
        });

谢谢!

1 个答案:

答案 0 :(得分:0)

您是否在developers.facebook.com上设置了应用程序?如果没有,您需要在使用Facebook之前这样做。

如果你这样做,这是我的工作认证代码(我可以发布图片,视频和状态更新到配置文件和我管理的任何页面,我的应用程序仍在测试中 - 我还没有通过Facebook审批流程)。

facebook = require('facebook');
facebook.appid = 'xxxxxxxxxxxxxxxxx'; //app id you'll get from Facebook when you create an app
facebook.permissions =  ['publish_actions, manage_pages'];

 facebook.createLoginButton({
    style : facebook.BUTTON_STYLE_WIDE
});

通过Facebook的弹出窗口进行身份验证并获得必要的权限后,您可以这样发布:

var acc = fb.getAccessToken();
facebook.requestWithGraphPath('me/feed?access_token='+ acc, {message: data}, "POST", showRequestResult); 

数据只是您要在状态更新中发布的文字。

如果您有其他人与您一起测试应用程序,请确保在Facebook应用程序设置下将其添加为测试人员,否则他们无法进行身份验证。

编辑:应该提到,如果你使用createLoginButton(),它会为你调用authorize()。这就是我的代码没有那个电话的原因。