How I can tag my facebook post with my facebook page in android

101 Views Asked by At

I am trying to post image/text on Facebook through my android app using Facebook sdk. Is it possible to tag my Facebook page with my post programatically??

Here is my code:

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>() {
}

I have tried open graph as well. Nothing is happening, even no dialog is showing to post on facebook. Here is the code :

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

There are 2 best solutions below

1
On

Tagging is only supported for open graphs and links for now.

2
On

You can share your image and tag friend using open graph 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();

You can refer this Facebook Document

Here you can get detail information about Open Graph API.