首页 > 解决方案 > 允许用户通过 Facebook 分享他们在我的网页游戏中的成就

问题描述

我试图让用户通过 Facebook 从我的基于网络的 HTML5 游戏中发布他们的分数/成就。我想要:

我读过的所有文档都已弃用:

游戏服务共享似乎很有希望,但它没有提供如何使其工作的示例代码。

如果我尝试使用带有测试元标记的共享对话框(他们说我需要设置元标记来自定义帖子):

<meta property="og:url"                content="http://www.nytimes.com/2015/02/19/arts/international/when-great-minds-dont-think-alike.html" />
<meta property="og:type"               content="article" />
<meta property="og:title"              content="When Great Minds Don’t Think Alike" />
<meta property="og:description"        content="How much does culture influence creative thinking?" />
<meta property="og:image"              content="http://static01.nyt.com/images/2015/02/19/arts/international/19iht-btnumbers19A/19iht-btnumbers19A-facebookJumbo-v2.jpg" />

我原以为它会显示《纽约时报》的形象,但它似乎不尊重标签

    FB.ui({
      method: 'share',
      href: 'https://spywatchlex.com',
    }, function(response){});

共享对话框似乎也支持作为参数,但我指定的quote引用文本没有出现在我的测试帖子中。

我只是想让用户单击按钮并分享他们获得的徽章,其中包含我在帖子中指定的文本。

我怎样才能做到这一点?

标签: javascripthtmlfacebook

解决方案


您可以quote将共享对话框的参数用于自定义文本:https ://developers.facebook.com/docs/sharing/reference/share-dialog#params

og:image正如您已经发现的那样,您必须提供图片作为标签。确保设置og:image:widthog:image:height


推荐阅读