Share dialog returns exception with “failed to generate preview for user facebook”

守給你的承諾、 提交于 2019-12-12 19:43:31

问题


I have switched to use the newly updated Facebook SDK for Android.

The above message was given in an FacebookException class when I tried to use the new Share Dialog.

Any reason why this happens?

Here's the code I'm using.

OpenGraphAction action = GraphObject.Factory.create(OpenGraphAction.class);
            action.setProperty("object", "http://object.url");

FacebookDialog shareDialog = new FacebookDialog.OpenGraphActionDialogBuilder(this, action, "appnamespace.action", "object")
                    .build();
uiHelper.trackPendingDialogCall(shareDialog.present());

回答1:


After hours and hours of trial and error, I've finally figured this out. Wish it was much simpler though. Facebook should provide a code generator.

Anyways, the solution for my problem is that the action word has to match the one that facebook set perfectly. The only way to see this is at the open graph code generator for types.

https://developers.facebook.com/apps/{app-id}/opengraph/types

You can find it at the above link at the action types section.

Now, take the namespace and action type that facebook provided and replace it with "appnamespace:action" below.

OpenGraphAction action = GraphObject.Factory.create(OpenGraphAction.class);
        action.setProperty("object", "http://object.url");

FacebookDialog shareDialog = new FacebookDialog.OpenGraphActionDialogBuilder(this, action, "appnamespace.action", "object")
                .build();
uiHelper.trackPendingDialogCall(shareDialog.present());



回答2:


I believe the issue is related to the "previewPropertyName" field int he OpenGraphActionDialogBuilder constructor.

new FacebookDialog.OpenGraphActionDialogBuilder(Activity activity, OpenGraphAction action, String previewPropertyName)

This must match the name of the property in the action that points to the OpenGraphObject itself. example

action.setProperty("previewPropertyName", openGraphObject);


来源:https://stackoverflow.com/questions/18401642/share-dialog-returns-exception-with-failed-to-generate-preview-for-user-faceboo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!