Facebook Instant Game - Uploading bundled zip file gives SDK reference error from Web Hosting

北城以北 提交于 2020-06-17 09:12:01

问题


When I try to upload my simple game/app, I get an error saying

"Games must reference one of our supported SDKs via our CDN."

I have given an SDK reference though. Isn't this the one?

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

I went through the SDK reference of facebook docs as well but it didn't work for me? Did anyone face same situation before or have an idea to fix this problem? thank you

I have a file 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:


<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 must have at least these three key-value pairs for the game to start.

Tested to work successfully.



来源:https://stackoverflow.com/questions/53941668/facebook-instant-game-uploading-bundled-zip-file-gives-sdk-reference-error-fro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!