明确共享不适用于 post - Facebook Android SDK Open Graph Story

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

我目前正在使用 Facebook Android SDK 3.19.1 来 post 我们用户时间轴上的 Open Graph Story。

故事已添加到用户的 activity 日志中,但未显示在他们的时间轴上。

我的故事有一个自定义动作和对象,我已经为我的动作设置了 "Explicitly Shared" 选项,并在代码中设置了相应的属性。我也已提交并获得 "publish_actions" 许可。

我是不是漏掉了什么?

 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();
}

我联系了 Facebook 的支持团队并得到以下回复:

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".

所以,我的问题显然根本不是问题。 :)

但是,我仍然认为该功能有点令人困惑。我认为“明确共享”post 会出现在用户的时间轴上,如果未选中“明确共享”选项,它就会出现上述行为。我想我的问题只是语义问题。