vendredi 8 mai 2015

Android Facebook version 4.0 open graph post bitmap failing

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", "http://ift.tt/1Rktcwo");


        // 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);

1 commentaire: