本文介绍了明确共享不工作的岗位 - Facebook的Andr​​oid SDK中的Open Graph的故事的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前使用Facebook的Andr​​oid SDK 3.19.1发布一个开放图谱的故事给我们的用户的时间表。

故事被添加到用户的活动日志,但是并不其时间轴上显示出来。

我有一个自定义操作和对象我的故事,我已经设置了明确共享选项,我的行动和code中的相应属性。我也提交并获得批准的publish_actions权限。

我失去了一些东西呢?

 私人无效postGraph(最终包B,最后Request.Callback回调){
    //设置请求回调来处理错误
    Request.Callback errorCallback =新Request.Callback(){

        @覆盖
        公共无效onCompleted(响应响应){
            //登录任何回应错误
            FacebookRequestError错误= response.getError();
            如果(错误!= NULL){
                callback.onCompleted(响应);
                Log.i(PostGraph,error.getErrorMessage());
            }
        }
    };

    //创建一个批处理请求
    RequestBatch requestBatch =新RequestBatch();

    //要求:舞台图像上传请求
    // --------------------------------------------

    布尔hasImage = b.containsKey(BUNDLE_PICTURE);
    //如果上传图片,成立了首批申请
    // 做这个事情。
    如果(hasImage){
        //设置图片上传请求参数
        位图图像= BitmapFactory.de codeFILE(b.getString(BUNDLE_PICTURE));

        //创建了图片上传请求
        请求imageRequest =请求
                .newUploadStagingResourceWithImageRequest(Session.getActiveSession(),
                        图像,errorCallback);

        //设置批次名称,以便您可以参考的结果
        //在后续的对象创建请求
        imageRequest.setBatchEntryName(imageUpload);

        //请求添加到批
        requestBatch.add(imageRequest);
    }

    //请求:对象请求
    // --------------------------------------------

    //设置的OpenGraphObject重新presenting书。
    OpenGraphObject OBJ = OpenGraphObject.Factory.createForPost(mGraphObjectName);
    如果(hasImage){
        obj.setImageUrls(Arrays.asList({结果= imageUpload:$ URI}));
    }
    如果(b.containsKey(BUNDLE_NAME)){
        obj.setTitle(b.getString(BUNDLE_NAME));
    }
    如果(b.containsKey(BUNDLE_LINK)){
        obj.setUrl(b.getString(BUNDLE_LINK));
    }
    如果(b.containsKey(BUNDLE_MESSAGE)){
        字符串消息= b.getString(BUNDLE_MESSAGE);
        如果(!TextUtils.isEmpty(消息)){
            obj.setDescription(b.getString(BUNDLE_MESSAGE));
            obj.setProperty(信息,b.getString(BUNDLE_MESSAGE));
        }
    }

    //创建对象创建请求
    请求objectRequest = Request.newPostOpenGraphObjectRequest(Session.getActiveSession()
            OBJ,errorCallback);

    //设置批次名称,以便您可以参考的结果
    //在后续发布操作要求
    objectRequest.setBatchEntryName(objectCreate);

    //请求添加到批
    requestBatch.add(objectRequest);

    //请求:发布操作要求
    // --------------------------------------------
    OpenGraphAction postAction = OpenGraphAction.Factory.createForPost(mGraphActionName);
    //从previous一批请求,请参阅ID的结果
    postAction.setProperty(目标,{结果= objectCreate:$ ID});
    postAction.setExplicitlyShared(真正的);
    postAction.setProperty(explicitly_shared,真);

    //创建发布操作要求
    更多的ActionRequest = Request.newPostOpenGraphActionRequest(Session.getActiveSession()
            postAction,回调);

    //请求添加到批
    requestBatch.add(ActionRequest里);

    //执行批处理请求
    requestBatch.executeAsync();
}
 

解决方案

我联系了Facebook的支持团队,并得到如下回应:

所以,我的问题显然不是一个问题,毕竟。 :)

不过,我还是会考虑的功能有点混乱。我想一个明确共享后会显示出用户的时间轴上,并且将有上述行为,如果没有选中了明确共享选项。我想我的问题,只是语义。

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();
}
解决方案

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

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.

这篇关于明确共享不工作的岗位 - Facebook的Andr​​oid SDK中的Open Graph的故事的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 21:24