使用Facebook开放图形故事v4

时间:2015-06-25 03:51:44

标签: android facebook facebook-graph-api facebook-opengraph

我正在使用facebook SDK 4.和开放图形故事api。我可以创建一个动作并在没有用户创建的图像时共享它,但是在添加图像时,我无法弄清楚如何将SharePhotoContent链接到创建的动作。

我的代码是:

ShareOpenGraphAction.Builder actionBuilder = new ShareOpenGraphAction.Builder();

    actionBuilder.setActionType("fbclimbmystats:on_sight"); //name space needed
actionBuilder.putObject("route", fbRoute); 
ShareOpenGraphAction action = actionBuilder.build();

//Create a Bitmap image to add
Bitmap bitmap = null;
if (photoPath !=  null){
bitmap = BitmapFactory.decodeFile(photoPath);
}

SharePhoto photo = null;
if (bitmap != null){
    photo = new SharePhoto.Builder()
    .setBitmap(bitmap)
    .setUserGenerated(true)
    .build();
}

ShareContent content;

if (photo!=null){
    content = new SharePhotoContent.Builder()
    .addPhoto(photo)
    .build();
}
else {
    ShareOpenGraphContent.Builder contentBuilder = new ShareOpenGraphContent.Builder();
    contentBuilder.setPreviewPropertyName("route"); // No namespace here
    contentBuilder.setAction(action);
    content =  contentBuilder.build();
}

因此,如果用户拍了照片,我想在故事中分享。为此,我创建了一个SharePhotoContent。但是它没有与动作相关联,显示的对话框基本上只是分享照片,这不是重点。

facebook的文档说明:

  

要将图书的图片附加到books.reads操作,应用程序应将图片作为位图加载,并在打开时将这些图片传递给“共享”对话框。

     

“分享”对话框显示故事的预览,并使用故事预览中上面传递的位图,而不是使用对象的图像。

那我错过了什么?我应该首先使用ShareOpenGraphContent启动对话,然后传递SharePhotoContent吗?如果是的话怎么样?

关于使用开放图表共享用户生成的照片,我还需要审核故事吗?

由于

1 个答案:

答案 0 :(得分:3)

看起来文档不正确。以下是将图像附加到OG共享对话框调用的示例。

6*6=36
相关问题