Android应用上的Open Graph错误:操作需要至少一个参考

时间:2017-12-19 10:24:36

标签: android facebook opengraph facebook-android-sdk

我在尝试发布 Open Graph 故事时遇到以下错误。

ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
                .putString("og:type", "games")
                .putString("og:title", "<Title>")
                .putString("og:url","<website>")
                .putString("og:image","<image link>")
                .putString("og:description", "Teste")
                .build();

        ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
                .setActionType("games.celebrate")
                .putObject("games", object)
                .build();

        ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
                .setPreviewPropertyName("games")
                .setAction(action)
                .build();

        ShareDialog.show(thisActivity, content);

我在文档中没有找到关于此属性 victory 的任何内容。

我用来发布故事的代码:

{{1}}

我怎样才能让它发挥作用?

1 个答案:

答案 0 :(得分:2)

根据https://developers.facebook.com/docs/reference/opengraph/action-type/games.celebrate/,您已经编写了如下代码块。尝试使用,而是进行更改,例如"og:type", "games.victory".putObject("games:victory", object)。所以在代码中进行更改。

ShareOpenGraphObject object = new ShareOpenGraphObject.Builder()
    .putString("og:type", "games.victory")
    .putString("og:title", "QoF")
    .putString("og:url","https://appsonfire33.wixsite.com/website")
    .putString("og:image:url","https://static.wixstatic.com/media/792c0f_ee1843bfce26447ab34eead294163182~mv2.png/v1/fill/w_80,h_80,al_c,usm_0.66_1.00_0.01/792c0f_ee1843bfce26447ab34eead294163182~mv2.png")
    .putString("og:description", "Teste")
    .build();

ShareOpenGraphAction action = new ShareOpenGraphAction.Builder()
    .setActionType("games.celebrate")
    .putObject("games:victory", object)
    .build();

ShareOpenGraphContent content = new ShareOpenGraphContent.Builder()
    .setPreviewPropertyName("games:victory")
    .setAction(action)
    .build();

ShareDialog.show(thisActivity, content);

希望得到这个帮助。