androidfacebookfacebook-graph-apifacebook-android-sdkfacebook-timeline

Explicitly Shared not working for post - Facebook Android SDK Open Graph Story


I am currently using the Facebook Android SDK 3.19.1 to post an Open Graph Story to our user's timeline.

The story is added to the user's activity log, but does not show up on their timeline.

I have a custom action and object for my story, and I have set the "Explicitly Shared" option for my Action and the corresponding properties in code. I have also submitted and been approved for the "publish_actions" permission.

Am I missing something here?

 private void postGraph(final Bundle b, final Request.Callback callback) {
    // Set up the request callback to handle errors
    Request.Callback errorCallback = new Request.Callback() {

        @Override
        public void onCompleted(Response response) {
            // Log any response error
            FacebookRequestError error = response.getError();
            if (error != null) {
                callback.onCompleted(response);
                Log.i("PostGraph", error.getErrorMessage());
            }
        }
    };

    // Create a batch request
    RequestBatch requestBatch = new RequestBatch();

    // Request: Staging image upload request
    // --------------------------------------------

    boolean hasImage = b.containsKey(BUNDLE_PICTURE);
    // If uploading an image, set up the first batch request
    // to do this.
    if (hasImage) {
        // Set up image upload request parameters
        Bitmap image = BitmapFactory.decodeFile(b.getString(BUNDLE_PICTURE));

        // Create the request for the image upload
        Request imageRequest = Request
                .newUploadStagingResourceWithImageRequest(Session.getActiveSession(),
                        image, errorCallback);

        // Set the batch name so you can refer to the result
        // in the follow-on object creation request
        imageRequest.setBatchEntryName("imageUpload");

        // Add the request to the batch
        requestBatch.add(imageRequest);
    }

    // Request: Object request
    // --------------------------------------------

    // Set up the OpenGraphObject representing the book.
    OpenGraphObject obj = OpenGraphObject.Factory.createForPost(mGraphObjectName);
    if (hasImage) {
        obj.setImageUrls(Arrays.asList("{result=imageUpload:$.uri}"));
    }
    if (b.containsKey(BUNDLE_NAME)) {
        obj.setTitle(b.getString(BUNDLE_NAME));
    }
    if (b.containsKey(BUNDLE_LINK)) {
        obj.setUrl(b.getString(BUNDLE_LINK));
    }
    if (b.containsKey(BUNDLE_MESSAGE)) {
        String message = b.getString(BUNDLE_MESSAGE);
        if (!TextUtils.isEmpty(message)) {
            obj.setDescription(b.getString(BUNDLE_MESSAGE));
            obj.setProperty("message", b.getString(BUNDLE_MESSAGE));
        }
    }

    // Create the request for object creation
    Request objectRequest = Request.newPostOpenGraphObjectRequest(Session.getActiveSession(),
            obj, errorCallback);

    // Set the batch name so you can refer to the result
    // in the follow-on publish action request
    objectRequest.setBatchEntryName("objectCreate");

    // Add the request to the batch
    requestBatch.add(objectRequest);

    // Request: Publish action request
    // --------------------------------------------
    OpenGraphAction postAction = OpenGraphAction.Factory.createForPost(mGraphActionName);
    // Refer to the "id" in the result from the previous batch request
    postAction.setProperty("object", "{result=objectCreate:$.id}");
    postAction.setExplicitlyShared(true);
    postAction.setProperty("explicitly_shared", "true");

    // Create the publish action request
    Request actionRequest = Request.newPostOpenGraphActionRequest(Session.getActiveSession(),
            postAction, callback);

    // Add the request to the batch
    requestBatch.add(actionRequest);

    // Execute the batch request
    requestBatch.executeAsync();
}

Solution

  • I contacted Facebook's Support Team and got the following response:

    This is By Design. Explicitly refers to the fact that the user made the decision to share a story. The share is guaranteed to be shown on the News Feed of the user, but not on their timeline.

    As you mentioned, it does show up in the Activity Log, and they can then select the drop down for a specific story by changing the selected option from "Allowed on Timeline" to "Shown on Timeline".

    So, my problem is apparently not a problem after all. :)

    But, I would still consider the functionality a little confusing. I would think an "Explicitly Shared" post would show up on the user's Timeline, and it would have the above behavior if the "Explicitly Shared" option was not checked. I guess my problem was just semantics.