How change photo privacy upload with Request.newUploadPhotoRequest?

664 views Asked by At

I'm trying to share a photo on facebook. First I want to upload it and then share the link. My problem is that the picture goes private, I have read the privacy parameter, but still have not managed to do this.

This is my method to upload the photo:

public static void publishPhoto(final Activity current, 
    final Bitmap photo, final String title) {

// start Facebook Login
Session.openActiveSession(current, true, new Session.StatusCallback() {

    // callback when session changes state
    @Override
    public void call(Session session, SessionState state,
        Exception exception) {
    if (session.isOpened()) {

        Request request = Request.newUploadPhotoRequest(session, photo, 
            new Request.Callback() {

        @Override
        public void onCompleted(Response response) {

            if (response.getError() == null) {

            String url = "https://www.facebook.com/photo.php?fbid="+getID(response);
            publishFeedDialog(current, null, null, null, url, null);
            }
            else {
            Log.d(TAG, response.toString());
            }
        }
        });

        JSONObject jsonObject = new JSONObject();
        try {
        jsonObject.put("value", "ALL_FRIENDS");
        } catch (JSONException e) {
        Log.e(TAG, "parse value of privacy to JSON: "+e.getMessage());
        }

        Bundle params = request.getParameters(); 
        params.putString("privacy", jsonObject.toString());
        params.putString(NAME, title);

        request.setParameters(params);

        request.executeAsync();

    } else
        Log.d(TAG, "login off");

    }
});
}

Sorry for my English.

1

There are 1 answers

1
Ming Li On

The user controls the "ceiling" that an app can post at, so if they've adjusted the permissions to be "Me Only", then there's nothing you as an app can do to post above that ceiling.

You can request a specific ceiling when you're requesting publish permissions. See the setDefaultAudience method on https://developers.facebook.com/docs/reference/android/current/class/Session.NewPermissionsRequest/

But be aware that the user can always change the default audience at any time, and you as an app cannot control that.