Facebook Instant Game-上传捆绑的zip文件会导致Web Hosting出现SDK参考错误

时间:2018-12-27 08:02:07

标签: javascript html sdk facebook-javascript-sdk facebook-instant-games

当我尝试上传简单的游戏/应用程序时,出现错误提示

  

“游戏必须通过CDN引用我们支持的SDK之一。”

我已经给出了SDK参考。这不是那个吗?

<script src="https://connect.facebook.net/en_US/fbInstant.6.2.js"></script>

我也通过了facebook docs的SDK参考,但是它对我不起作用? 有没有人以前遇到过同样的情况或有解决此问题的想法?谢谢

我有一个文件index.html

INDEX.HTML

 <html>
  <head>
    <title>
        this is test
</title>
<style>
body {
  width: 400px;
  height: 400px;
  position: 0;
  background: yellow;
 }
    #heading1{

  position: absolute;

}
    </style>
</head>

<body>
<h1 id="heading1">
This is h1.
</h1>
<button onclick="myFunction()">Move the heading</button>
<script>
var ran = Mathfloor.Math.Random()*1;
function myFunction() {
var move= document.getElementById("heading1");
 var pos = 0;
  var id = setInterval(frame, 5);
  function frame() {
if (pos == 350) {
 clearInterval(id);
  var id1 = setInterval(framenext, 5);
} else {
  pos++; 
  if (ran ==1) {
  move.style.top = pos + "px"; }else {
  move.style.left = pos + "px"; }
}
}
     function framenext() {
if (pos == 0) {
  clearInterval(id1);
  var id = setInterval(framenext, 5);
} else {
  pos--; 
  if (ran ==1) {
  move.style.top = pos + "px"; }else {
  move.style.left = pos + "px"; }
   }
   }

    }
</script>
<script src="https://connect.facebook.net/en_US/fbInstant.6.2.js"</script>
    </body>
</html>

fbapp-config.json

 {
    "instant_games":{
     "navigation_menu_version": "NAV_FLOATING",
     }
  }

1 个答案:

答案 0 :(得分:0)

<body>
<script src="https://connect.facebook.net/en_US/fbinstant.6.2.js"></script>
<h1 id="heading1">
    This is h1.
</h1>
<button onclick="myFunction()">Move the heading</button>
<script>
    window.onload = function () {
        FBInstant.initializeAsync().then(function () {
            FBInstant.setLoadingProgress(100);
        });
        FBInstant.startGameAsync().then(function () {
            startGame();
        })
    };
</script>
<script>
    var ran = Math.floor(Math.random() * 1);
    your script codes here...
</script>
</body>
</html>

fbapp-config.json

{
  "instant_games": {
    "platform_version": "RICH_GAMEPLAY",
    "orientation": "LANDSCAPE",
    "navigation_menu_version": "NAV_FLOATING"
  }
}
  

fbapp-config.json必须至少具有以下三个键值对   游戏开始。

测试成功。