Frage

While sharing my app via facebook, it works fine but on the post it says "only me". I want that the post should be seen by all friends. Below is the code snippet I am using:

 private static final List<String> PERMISSIONS = Arrays.asList("publish_actions");

In on create method:

 com.facebook.Settings.addLoggingBehavior(LoggingBehavior.INCLUDE_ACCESS_TOKENS);

     com.facebook.Session session = com.facebook.Session.getActiveSession();
        if (session == null) {
            if (savedInstanceState != null) {
                session = com.facebook.Session.restoreSession(this, null, statusCallback, savedInstanceState);
            }
            if (session == null) {
                session = new com.facebook.Session(this);
            }
            com.facebook.Session.setActiveSession(session);
            if (session.getState().equals(SessionState.CREATED_TOKEN_LOADED)) {
                session.openForRead(new com.facebook.Session.OpenRequest(this).setCallback(statusCallback));

                session.openForPublish(new Session.OpenRequest(this)
                .setCallback(statusCallback)
                .setLoginBehavior(SessionLoginBehavior.SUPPRESS_SSO)
                .setPermissions(Arrays.asList("publish_actions")));


            }

I am using foolowing code for publishing story

private void uploadStoryUsingFacebook() {

//  Toast.makeText(HomeScreenActivity.this, "NOw we can post story !!!",2000).show();
      // Check for publish permissions    
    Session session = Session.getActiveSession();
    List<String> permissions = session.getPermissions();
    if (!isSubsetOf(PERMISSIONS, permissions)) {
        pendingPublishReauthorization = true;
        Session.NewPermissionsRequest newPermissionsRequest = new Session
                .NewPermissionsRequest(this, PERMISSIONS);
    session.requestNewPublishPermissions(newPermissionsRequest);
        return;
    }

     Bundle params = new Bundle();
        params.putString("name", "");
        params.putString("link", "some link");
        params.putString("picture", "some picture");



        FeedDialogBuilder builder = new FeedDialogBuilder(HomeScreenActivity.this, Session.getActiveSession(), params);

        builder.setOnCompleteListener(new OnCompleteListener() {

            @Override
            public void onComplete(Bundle values, FacebookException error) {


                if (error != null) {

                }

                if (error == null) {

                    // When the story is posted, echo the success
                    // and the post Id.

                    final String postId = values.getString("post_id");

                    if (postId != null) {
                        Toast.makeText(HomeScreenActivity.this,"Posted story, id: "+postId,Toast.LENGTH_SHORT).show();
                    } else {
                        // User clicked the Cancel button
                        Toast.makeText(HomeScreenActivity.this, "Publish cancelled",Toast.LENGTH_SHORT).show();
                    }
                } else if (error instanceof FacebookOperationCanceledException) {
                    // User clicked the "x" button
                    Toast.makeText(HomeScreenActivity.this.getApplicationContext(), "Publish cancelled", Toast.LENGTH_SHORT).show();
                } else {
                    // Generic, ex: network error
                    Toast.makeText(HomeScreenActivity.this.getApplicationContext(), "Error posting story",Toast.LENGTH_SHORT).show();
                }


            }
        });

        builder.build().show();


}

private boolean isSubsetOf(Collection<String> subset, Collection<String> superset) {
for (String string : subset) {
    if (!superset.contains(string)) {
        return false;
    }
}
return true;

}

Can anyone please guide me on solving this issue?

War es hilfreich?

Lösung

Try this ->

  1. Remove your app from your fb account (Follow this link)
  2. Now clear all the data on device.
  3. Try to publish again from your app, now this time it will ask you for permissions, along with that you can see that there is dropdown at bottom for post visibility, change it to public.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top