0

I am not able to post Facebook using the custom-ui project of socialauth-android.

Here is the error log.

10-31 13:18:05.124: D/SocialAuthError(21880): org.brickred.socialauth.exception.SocialAuthException: org.brickred.socialauth.exception.SocialAuthException: Status not updated. Return Status code :403
10-31 13:18:05.124: W/System.err(21880): org.brickred.socialauth.android.SocialAuthError: Message Not Posted
10-31 13:18:05.124: W/System.err(21880):    at org.brickred.socialauth.android.SocialAuthAdapter$6.run(SocialAuthAdapter.java:868)
10-31 13:18:05.124: W/System.err(21880):    at java.lang.Thread.run(Thread.java:818)

I am not able to find the issue. I am using the same API keys got from the Github source.

Alex
  • 8,461
  • 6
  • 37
  • 49

1 Answers1

0

You are getting 403 Authentication Error that clearly means that your app is presently not authorized to publish on Facebook profile of the user.

There is some problem the way you are trying to use Facebook APIs. I would suggest you to the latest Facebook SDK for Android as some of the older methods may be deprecated. Let me tell you the approach for doing this right way. (I recently implemented latest Facebook SDK)

  • You need a permission

There are some specific permissions that you require to do some specific operations with Facebook SDK. For example, You need publish_actions permission if you want your app to post status on user's profile.

Check Out It says,

For example, the publish_actions permission lets you post to a person's Facebook Timeline.

  • How to get Permissions

You need to show the user a login button which will ask him to do login with his facebook account and notifying the user what your app may do with his Facebook profile. It will show the permissions. In your case you need to add a login button with publish_actions permission. Once the user accepts it, your app becomes authorized to post status.

Complete Tutorial is here for doing the login process of Facebook with permissions.

You will need to do the following,

LoginButton authButton = (LoginButton) view.findViewById(R.id.authButton);
authButton.setFragment(this);
authButton.setReadPermissions(Arrays.asList("user_likes", "user_status", "publish_actions"));
return view;

So you can see we are asking the user to give you the publish_actions permission. It is not mandatory to include user_likes or user_status permissions. You can remove them if you don't need them.

  • Next what after login

After the user logs in, you get an authentication token in your session with Facebook. So now you can use that to publish on user's profile.

  • How to post

Now there are many ways to publish posts or status on Facebook. The first one I would like to discuss is using the Graph API

Here is somewhat code, you can use to publish to facebook.

Session session = Session.getActiveSession();

new Request(
    session,
    "/me/feed",
    null,
    HttpMethod.POST,
        new Request.Callback() {
            public void onCompleted(Response response) {

            }
        }
).executeAsync();

NOTE

You do also need to create developer account with facebook and add your app to its dashboard, generate an app_id and mention the same in your AndroidManifest.xml file.