facebook - 在 https 服务器上测试 Facebook 即时游戏时,网站继续以 0% 加载
问题描述
对不起我的英语不好,我做的事情(测试我的项目)就像在官方文档(https://developers.facebook.com)中一样。我用命令测试我的证书,没有错误。当我创建一个 https 服务器时,也没有错误。您可以在此处找到该项目:developers.facebook.com。
首先,我测试localhost:8080
,它显示我不安全并且 https 是红色的,当项目被嵌入时,是的,这个 url 是https://www.facebook.com/embed/instantgames/YOUR_GAME_ID/player?game_url=https://localhost:8080
这个网站似乎无法工作,它继续以 0% 的速度加载。我不知道为什么。有人可以帮我吗?谢谢你的帮助!
解决方案
您必须实际通知 API 您已完成加载。可以在此页面上找到最低代码,如下所示:
<script src="https://connect.facebook.net/en_US/fbinstant.6.2.js"></script>
<script>
FBInstant.initializeAsync()
.then(function() {
});
// Once all assets are loaded, tells the SDK
// to end loading view and start the game
FBInstant.startGameAsync()
.then(function() {
// Retrieving context and player information can only be done
// once startGameAsync() resolves
var contextId = FBInstant.context.getID();
var contextType = FBInstant.context.getType();
var playerName = FBInstant.player.getName();
var playerPic = FBInstant.player.getPhoto();
var playerId = FBInstant.player.getID();
// Once startGameAsync() resolves it also means the loading view has
// been removed and the user can see the game viewport
game.start();
});
</script>
推荐阅读
- tcp - 在 TCP 中快速重传后,接收方发送的 ACK 号是多少?
- android - 将字节数组复制到分配中的Android渲染脚本问题
- c# - 如何使用 POCO 类反序列化包含数字的 JSON 属性?
- javascript - 在 react/redux 中调用 store.subscribe 中的函数
- java - 谷歌地图 API:如何使标记可点击?
- css - CSS 网格中的图像
- javascript - 如何演示函子的 MAP 方法关联属性
- amazon-web-services - 如何计算对特定 RDS 实例进行增强监控的成本。
- data-visualization - 如何在 Tableau 中对相同州/省的点进行聚类
- javascript - 打字稿没有加载大的json文件