Post to user facebook wall not working when Facebook app is installed on device/emulator

后端 未结 3 640
情书的邮戳
情书的邮戳 2021-01-14 03:09

I\'ve built an activity that uses this implementation (see the accepted answer) to post a status update on a user\'s facebook wall.

It works with no problem if the e

相关标签:
3条回答
  • 2021-01-14 03:25

    I have found a workaround but it is not the best so far.

    facebook.authorize(activity, PERMISSIONS, Facebook.FORCE_DIALOG_AUTH, 
                    new LoginDialogListener());
    

    This will force that your app does not use the SSO if official facebook app is installed on the device. But there must be a better solution because there are apps out there which use sso with the official facebook app.

    0 讨论(0)
  • 2021-01-14 03:31
    private static final String[] PERMISSIONS =
            new String[] {"publish_stream", "read_stream", "offline_access"};  
    
    
    
    
    @Override
    public void onClick(View v)
    {
        if (v == facebookPostButton)
        {
            mAsyncRunner    = new AsyncFacebookRunner(mFacebook);
                                       mAsyncRunner.request(mFacebook.logout(getApplicationContext()), new LogoutListener());
                            mFacebook.authorize(FacebookImplement.this, PERMISSIONS, new AuthorizeListener());
        }
    }
    
    
    
    public class AuthorizeListener extends BaseDialogListener {
    
            public void onComplete(Bundle values) {
    
               Bundle params = new Bundle();
               params.putString("message"," Message");
           params.putString("description", "Wall Posting Description");        
            mAsyncRunner.request("me/feed", params, "POST",
                    new UploadListener());         
    
            }
    

    }

    public class UploadListener extends BaseRequestListener {
    
            public void onComplete(final String response) {
                  mAsyncRunner.request(mFacebook.logout(getApplicationContext()), new LogoutListener());
    }
    

    }

     public class LogoutListener extends BaseRequestListener {
    
    
            public void onComplete(final String response) {         
    
    
    
            }
        }
    

    May be this code helps you. If there is any problem then ask without any issue.

    0 讨论(0)
  • 2021-01-14 03:32

    It is because when you logged in the facebook account then your login session is created in the device. You have to logout from the facebook after doing your task.

    0 讨论(0)
提交回复
热议问题