Facebook publish_actions error in Titanium

250 Views Asked by At

Im trying to use publish_actions in Titanium for my app, but Im getting the "sdk facebook error 5". I saw that Facebook recently changed this permission and now you have to submit the app, screenshot and other things for approval. There is some documentation for using this permission as developers, like the scope attribute, but i ve found none for titanium. Im using my facebook account which is administrator of the app.

This code is currently not working:

        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");
                }
            }
        });

Thanks!

1

There are 1 best solutions below

0
On

Did you set up an application at developers.facebook.com? If not, you need to do that before you can work with Facebook.

If you did, here's my working authentication code (I can post images, videos and status updates to profiles and any pages I manage and my application is still in testing - I haven't gone through the Facebook approval process yet).

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
});

After you authenticate and gain the necessary permissions by going through Facebook's pop ups, you can post like this:

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

data is just the text you want to post in your status update.

If you are having anybody else test the app with you, make sure you add them as a tester under your Facebook app settings, otherwise they cannot authenticate.

edit: Should have mentioned, if you use the createLoginButton() it calls authorize() for you. That's why my code doesn't have that call.