我目前正在使用Facebook Android SDK 3.19.1向用户的时间线发布Open Graph Story。
该故事已添加到用户的活动日志中,但未显示在其时间轴上。
我为自己的故事制作了自定义动作和对象,并设置了"明确共享"我的Action的选项以及代码中的相应属性。我还提交并批准了" 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();
}
答案 0 :(得分:1)
我联系了Facebook的支持团队,得到了以下回复:
这是By Design。明确指出用户决定分享故事的事实。该份额保证显示在用户的新闻Feed上,但不会显示在其时间轴上。
如您所述,它确实显示在活动日志中,然后他们可以通过将所选选项从“允许在时间轴上”更改为“在时间轴上显示”来选择特定故事的下拉列表。
所以,我的问题显然不是问题。 :)
但是,我仍然认为这个功能有点令人困惑。我认为“显式共享”帖子会显示在用户的时间轴上,如果未选中“明确共享”选项,它将具有上述行为。我想我的问题只是语义。