我如何用android中的facebook页面标记我的facebook帖子

时间:2017-07-20 05:47:14

标签: android facebook-page facebook-tag

我试图通过我的Android应用程序使用Facebook sdk在Facebook上发布图像/文本。是否可以用我的帖子以编程方式标记我的Facebook页面?

这是我的代码:

SharePhoto photo = new SharePhoto.Builder()
.setBitmap(bitmap)
.setCaption(shareText)
.setUserGenerated(false)
.build();
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();

ShareApi.share(content, new FacebookCallback<Sharer.Result>() {
}

我也尝试过打开图表。什么都没发生,即使没有对话显示在Facebook上发布。这是代码:

List<String> peopleIds = new ArrayList<String>(1);
peopleIds.add("AaJa_TfLYQJXLuTCQyNBG3dHoK7WCtpXePE1_qBFVPcNB68_KyGTRTXxjKWg6L1qbStB75WSEZ8OAmRxjbA");

SharePhoto photo = new SharePhoto.Builder()
.setBitmap(bitmapWaterMark)
.setCaption(shareText)
.setUserGenerated(true)
.build();

ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
.putString("og:type", "aaa")
.putString("og:title", "bbb")
.putString("og:description", "ccc")
.putString("books:isbn", "ddd")
.build();

ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
.putObject("book", object)
.putPhoto("image", photo)
.build();

ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
.setPreviewPropertyName("book")
.setAction(action)
.setPeopleIds(peopleIds)
.build();


ShareDialog.show(UploadFunnyContentActivity.this, content);

2 个答案:

答案 0 :(得分:0)

目前仅支持打开的图表和链接。

答案 1 :(得分:0)

您可以使用开放图谱API分享您的图片和标记朋友。

// Tag one or multiple people using their ids
List peopleIds = ...;

// Tag a place using the place's id
List placeId = ...;

SharePhoto photo = new SharePhoto.Builder()
    .setBitmap(bitmap)
    .setUserGenerated(true)
    .build();

// Create an action
ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
    .setActionType("books.reads")
    .putObject("book", object)
    .putPhoto("image", photo)
    .setPeopleIds(peopleIds)
    .setPlaceIds(placeId)
    .build();

您可以参考此Facebook Document

您可以在此处获取有关Open Graph API的详细信息。