I have the code below attempting to post an Open Graph story with attached bitmap image. The Bitmap is about 1 Meg in size so is within the Facebook limitation. The Share Dialog is displayed and the post will work but with no image showing! I do have appropriate provider entry in the manifest and I get no reported errors. Any thoughts on what may be wrong?
// get App Facebook namespace
final String fbNamespace = gameIdentity.getFbNamespace();
// Create an object
ShareOpenGraphObject.Builder object = new ShareOpenGraphObject.Builder()
.putString("og:type", fbNamespace + ":board")
.putString("og:title", params.getString("name"))
.putString("og:description", params.getString("caption"))
.putString("og:url", "https://facebook.com/Example");
// if we have an image, add to graph object
if (image != null) {
// build Photo object
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(image)
.setUserGenerated(true)
.build();
// add to graph object
object.putPhoto(fbNamespace + ":board", photo);
}
// Create an action
ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
.setActionType(fbNamespace + ":complete")
.putObject("board", object.build())
.build();
// Create the content
ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
.setPreviewPropertyName("board")
.setAction(action)
.build();
// initiate share process
ShareDialog shareDialog = new ShareDialog(this);
shareDialog.show(content);
Well try to use
// add to graph object
object.putPhoto("og:image", photo);
or use
SharePhotoContent content = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
But you have to have the facebook app v7.0 and above installed on the phone
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments