在https服务器上测试Facebook即时游戏时,该网站将继续加载0%

时间:2018-06-08 13:10:27

标签: facebook typescript

对不起我的英语不好,我就像在官方文件(https://developers.facebook.com)中做的那样(测试我的项目)。我用命令测试我的证书,没有错误。当我制作https服务器时,也没有错误。你可以在这里找到这个项目:developers.facebook.com。

首先,我测试localhost:8080,它显示我不安全,https是红色,当项目嵌入时,是的,网址是https://www.facebook.com/embed/instantgames/YOUR_GAME_ID/player?game_url=https://localhost:8080,这个网站似乎不起作用,它继续加载量为0%。我不知道为什么。有人可以帮帮我吗?谢谢你的帮助!

1 个答案:

答案 0 :(得分:0)

您必须实际告知API您已完成加载。最低代码可以在this page上找到,如下所示:

<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>