【问题标题】:Explicitly Shared not working for post - Facebook Android SDK Open Graph Story明确共享不适用于帖子 - Facebook Android SDK Open Graph Story
【发布时间】:2015-01-23 21:17:45
【问题描述】:

我目前正在使用 Facebook Android SDK 3.19.1 将 Open Graph Story 发布到我们用户的时间线。

故事会添加到用户的活动日志中,但不会显示在他们的时间线上。

我的故事有一个自定义动作和对象,并且我已经为我的动作和代码中的相应属性设置了“显式共享”选项。我也提交并获得了“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();
}

【问题讨论】:

    标签: android facebook facebook-graph-api facebook-android-sdk facebook-timeline


    【解决方案1】:

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

    这是设计使然。明确指用户决定分享故事的事实。分享保证会显示在用户的新闻提要上,但不会显示在他们的时间线上。

    正如您所提到的,它确实显示在活动日志中,然后他们可以通过将所选选项从“时间轴上允许”更改为“时间轴上显示”来选择特定故事的下拉列表。

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-09-28
      • 1970-01-01
      • 1970-01-01
      • 2014-02-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多