1

I have downloaded and setup the android simple facebook sdk from github. I have made a simple page to test publishing a feed, and I was able to get to the point where I can add a message and click "share". However, once I click share, a progress dialog comes up that says "sending..." and then it goes away but nothing is sent. I printed the error message and it just says "Cancelled by user".

Here is the code I have, its just a button that logs in, and on success tries to post a feed.

Button postStuff;
private UiLifecycleHelper uiHelper;

Permission[] permissions = new Permission[] {
        Permission.USER_PHOTOS,
        Permission.EMAIL,
        Permission.PUBLISH_ACTION
    };
SimpleFacebookConfiguration configuration = new SimpleFacebookConfiguration.Builder()
    .setAppId("My-App-ID")
    .setNamespace("my_namespace")
    .setPermissions(permissions)
    .build();
SimpleFacebook mSimpleFacebook;


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.fbtest);

    SimpleFacebook.setConfiguration(configuration);

    postStuff = (Button) findViewById(R.id.postStuff);

    postStuff.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            OnLoginListener onLoginListener = new OnLoginListener() {
                @Override
                public void onLogin() {
                    // change the state of the button or do whatever you want
                    Log.i("fb login", "Logged in");

                    OnPublishListener onPublishListener = new OnPublishListener() {
                        @Override
                        public void onComplete(String postId) {
                            Log.i("fb post", "Published successfully. The new post id = " + postId);
                        }

                        @Override
                        public void onFail(String reason) {
                            Log.i("fb post","failed: " + reason);
                        }

                        /* 
                         * You can override other methods here: 
                         * onThinking(), onFail(String reason), onException(Throwable throwable)
                         */
                    };
                    Feed feed = new Feed.Builder()
                    .setMessage("Check this out.")
                    .setName("Home Shop Guide App for Android")
                    .setCaption("Win prizes and deals daily")
                    .setDescription("User just won $500 from a daily scratchoff prize. You could be the next winner!")
                    .setPicture("https://homeshopguide.com/images/logo.png")
                    .setLink("https://homeshopguide.com/")
                    .build();
                    mSimpleFacebook.publish(feed, true, onPublishListener);
                }

                @Override
                public void onNotAcceptingPermissions(Permission.Type type) {
                    // user didn't accept READ or WRITE permission
                    Log.w("fb login", String.format("You didn't accept %s permissions", type.name()));
                }

                @Override
                public void onThinking() {
                    // TODO Auto-generated method stub
                    Log.i("fb login", "thinking");
                }

                @Override
                public void onException(Throwable throwable) {
                    // TODO Auto-generated method stub
                    Log.i("fb login", "exception" + throwable.getLocalizedMessage());
                }

                @Override
                public void onFail(String reason) {
                    // TODO Auto-generated method stub
                    Log.i("fb login", "failed: " + reason);
                }

            };
            mSimpleFacebook.login(onLoginListener);

        }

    });


}

@Override
public void onResume() {
    super.onResume();
    mSimpleFacebook = SimpleFacebook.getInstance(this);

}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    mSimpleFacebook.onActivityResult(this, requestCode, resultCode, data); 
    super.onActivityResult(requestCode, resultCode, data);
} 

And this is what shows up in the error log when i press the button:

03-19 17:01:53.537: I/fb login(31226): Logged in
03-19 17:01:53.647: D/OpenGLRenderer(31226): Flushing caches (mode 1)
03-19 17:01:53.957: D/OpenGLRenderer(31226): Flushing caches (mode 0)
03-19 17:02:05.527: I/fb post(31226): failed: Canceled by user

EDIT: I tried again the next day (before making any changes) and the log showed that the post was successful. However, the facebook account I am using to develop with is a business account and I do not know where the feed got posted to.

As sromku suggested I put the app in live mode to test with a normal facebook account. I am still receiving the "Canceled by user" error. however, when I checked my wall the post was there as expected. My question now is am I doing something wrong to receive this error or is it just an error showing up when it is not supposed to.

JStephen
  • 1,059
  • 3
  • 13
  • 28
  • Have you canceled the facebook app from being in a sandbox mode? – sromku Mar 19 '14 at 21:42
  • No, it is still not public but I am using the facebook account that is set up as the developer and administrator. I tried with a different account but could only get this far with the developer account. – JStephen Mar 20 '14 at 14:53
  • So it sounds reasonable. You can get info from facebook only from dev account like you said. It is because your app is still isnt public. Once you put it on public, every account will able to request and get data.. – sromku Mar 20 '14 at 15:09
  • Ok, I ran it again and it says it is posting now even though i didn't change anything. However I can't find where its posting to (the account is a business account). So I made it live and tested it on the other normal account and it is still saying action cancelled by user. I was able to get further with this account now that it is live, but having the same problem. – JStephen Mar 20 '14 at 15:38
  • @sromku - I'm experiencing this as well. My app is published (not in sandbox mode). – Lior Apr 25 '14 at 20:00
  • @sromku I have just done the same, and getting cancelled by user, but on my FB wall, do i need to request publish_actions within the developer site – RuAware May 13 '14 at 19:24
  • @sromku It doesn't matter if the app is on sandbox or published it always fails with "Cancelled by user" – Julio Mendoza Jul 25 '14 at 22:20

1 Answers1

0

This behaviour has been fixed in simple facebook 2.2 release. I've been experiencing the same issue and it got fixed after updating the lib. Check this issue for the details.

fedepaol
  • 6,834
  • 3
  • 27
  • 34