Reputation: 494
I have a open session.when i try to publish friends wall post it says i don't have permission to do this.how can i set stream publish permission to already open session in android.
Upvotes: 1
Views: 1817
Reputation: 15662
If you have an already open session, you should check whether it already has the "publish_stream" or "publish_action" permission, and if it doesn't, call requestNewPublishPermissions. Something like
Session session = Session.getActiveSession();
List<String> permissions = session.getPermissions();
if (!permissions.contains("publish_actions")) {
Session.NewPermissionsRequest newPermissionsRequest = new Session.NewPermissionsRequest(this, Arrays.asList("publish_actions"))
.setDefaultAudience(SessionDefaultAudience.FRIENDS);
session.requestNewPublishPermissions(newPermissionsRequest);
}
Upvotes: 5
Reputation: 23638
You can set the permission of publish as below :
private static final String[] PERMISSIONS = new String[] { "publish_stream" };
And check this permission in the authorize method of facebook as below:
public void loginAndPostToWall() throws CustomException { try { m_facebook.authorize(FacebookShareActivity.this, PERMISSIONS, Facebook.FORCE_DIALOG_AUTH, new LoginDialogListener()); } catch (Throwable p_e) { throw new CustomException(TAG + "Error in loginAndPostToWall()", p_e); } }
Upvotes: 0