Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Facebook OG Share not working correctly with pictures. #93

Open
WillCalderwood opened this issue Feb 8, 2016 · 0 comments
Open

Facebook OG Share not working correctly with pictures. #93

WillCalderwood opened this issue Feb 8, 2016 · 0 comments

Comments

@WillCalderwood
Copy link

I'm not sure if this is going to be a RoboVM issue, but it seems a fairly major bug if Facebook let it slip through the net - that said, I know the picture is getting as far as the Facebook SDK as it previews correctly.

OG sharing appears to be working fine with the latest SDK, sharing both with and without pictures opens the ShareDialog as expected. If a picture is included it previews correctly in the displayed dialog. When clicking Post everything closes as expected, there are no errors logged and a little tick shows saying "Shared".

The problem is apparent when viewing on Facebook, there is no picture displayed. There is a box shown where you'd expect to see the picture, but there's nothing in it.

image

Here's some code based on Facebook samples that should work.

private void doSimpleShare(Pixmap pixmap) {
    ByteArrayOutputStream os = new ByteArrayOutputStream();

    // Convert the pixmap into a PNG as that's what we need for the Android bitmap object
    PixmapIO.PNG png = new PixmapIO.PNG();
    try {
        png.write(os, pixmap);
    } catch (IOException e) {
        e.printStackTrace();
        WordStormGame.getAnalytics().logException(e);
        WordStormGame.showErrorDialogThreadSafe(WordStormGame.getString("An_unexpected_error_occurred"));
        return;
    }

    NSData imageData = new NSData(os.toByteArray());
    UIImage image = new UIImage(imageData);

    FBSDKSharePhoto photo = new FBSDKSharePhoto();
    photo.setImage(image);
    photo.setUserGenerated(true);
    photo.setCaption("A Game of Thrones");

    FBSDKShareOpenGraphObject object = new FBSDKShareOpenGraphObject();
    object.putString("og:type", "books.book");
    object.putString("og:title", "A Game of Thrones");
    object.putString("og:description", "In the frozen wastes to the north of Winterfell, sinister and supernatural forces are mustering.");
    object.putString("books:isbn", "0-553-57340-3");
    object.putPhoto("og:image", photo);

    FBSDKShareOpenGraphAction action = new FBSDKShareOpenGraphAction();
    action.setActionType("books.reads");
    action.putObject("books:book", object);

    FBSDKShareOpenGraphContent content = new FBSDKShareOpenGraphContent();
    content.setPreviewPropertyName("books:book");
    content.setAction(action);

    FBSDKShareDialog dialog = new FBSDKShareDialog();
    dialog.setShareContent(content);
    dialog.show();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant