有人可以帮助我吗?我制作了一个自定义的故事,它完美无缺,我只能弄清楚这种常见的动作类型有什么问题。窗口只是在打开和关闭后的第二个例外。
public void publishCommonOpenGraphStory() {
OpenGraphObject book = OpenGraphObject.Factory.createForPost("book");
book.setProperty("title", "Harry Potter");
book.setProperty("description", "Description of HP book.");
book.setProperty("url", "https://www.facebook.com/pages/Harry-Potter-6/115538755123952?rf=376474059116356");
book.setProperty("image", "<img_url>"); // url was long so I cut it there
OpenGraphAction ogAction = GraphObject.Factory.create(OpenGraphAction.class);
ogAction.setProperty("book", book);
ogAction.setType("books.reads");
FacebookDialog shareDialog = new FacebookDialog.OpenGraphActionDialogBuilder(this, ogAction, "book")
.build();
uiHelper.trackPendingDialogCall(shareDialog.present());
我得到一个错误:
07-25 14:44:19.671 31907-31907/com.example.facebooktest E/ActivityResult.onComplete﹕ Error: com.facebook.FacebookException: Failed to generate preview for user.
我不知道问题出在哪里,对我来说一切似乎都没问题。
答案 0 :(得分:0)
我弄清楚该方法有什么问题。 当使用常见的facebook对象(例如本例中的books.book)时,您必须检查每个对象必需的字段(非空)。 我不得不将book isbn number添加为属性,必须填写:
book.getData().setProperty("isbn", "2-07-057267-6");
这可以在facebook开发者网站的docs中找到。 例: books.book doc
整个方法代码现在看起来像这样:
public void publishCommonOpenGraphStory() {
OpenGraphObject book = OpenGraphObject.Factory.createForPost("books.book");
book.setProperty("title", "Harry Potter");
book.setProperty("description", "Description of HP book.");
book.setProperty("url", "https://www.facebook.com/pages/Harry-Potter-6/115538755123952?rf=376474059116356");
book.setProperty("image", "<img link>");
book.getData().setProperty("isbn", "2-07-057267-6");
OpenGraphAction ogAction = GraphObject.Factory.create(OpenGraphAction.class);
ogAction.setProperty("book", book);
ogAction.setType("books.reads");
FacebookDialog shareDialog = new FacebookDialog.OpenGraphActionDialogBuilder(this, ogAction, "book")
.build();
uiHelper.trackPendingDialogCall(shareDialog.present());
}