javascript - 允许用户通过 Facebook 分享他们在我的网页游戏中的成就
问题描述
我试图让用户通过 Facebook 从我的基于网络的 HTML5 游戏中发布他们的分数/成就。我想要:
- 自定义作为帖子的一部分写入的文本
- 分享他们的成就徽章的快照(指定图片的 URL)
我读过的所有文档都已弃用:
- 用户评分
- Feed Dialog -
picture
是我需要的字段,已弃用 - 分数和成就- 计划弃用
游戏服务共享似乎很有希望,但它没有提供如何使其工作的示例代码。
如果我尝试使用带有测试元标记的共享对话框(他们说我需要设置元标记来自定义帖子):
<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
引用文本没有出现在我的测试帖子中。
我只是想让用户单击按钮并分享他们获得的徽章,其中包含我在帖子中指定的文本。
我怎样才能做到这一点?
解决方案
您可以quote
将共享对话框的参数用于自定义文本:https ://developers.facebook.com/docs/sharing/reference/share-dialog#params
og:image
正如您已经发现的那样,您必须提供图片作为标签。确保设置og:image:width
和og:image:height
。
推荐阅读
- python - 无法安装包“kivy”(pycharm)
- mongodb - 从 Spark 写入 mongoDB
- php - 403 禁止 - 如何解决?
- java - 将 reflect.Method 放到一个函数式接口中
- android - 反应原生应用程序的 Firebase 兼容性问题
- php - 有没有办法判断用户上传的文件是否是服务器脚本?
- node.js - 为 mongodb 创建索引时,Node.js 应用程序崩溃
- windows - 搜索维护的二进制差异/补丁工具或库
- android - 在 kotlin 中扩展时类所需的类型参数
- c++ - crypt in c++ returning different strings(or no string at all)