Tuesday, January 21, 2020

Create FB Instant Game

1. index.html

<html>
<body>
<script src="https://connect.facebook.net/en_US/fbinstant.6.2.js"></script>
whatever...
</body>
</html>
2. main.js
FBInstant.initializeAsync()
    .then(function() {
        var progress = 0;
        var interval = setInterval(function() {
            progress += 100;
            FBInstant.setLoadingProgress(progress);
            if (progress >= 95) {
                clearInterval(interval);
                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();
                            //start Game
                            startYourGame();
                        }
                    )
            }
        }, 100);
    });

Error:
Sorry the Game is not available at the moment
- missing adding Product
  - Create FB App --> Add Instant Game

Local Test
https://www.facebook.com/embed/instantgames/APP_ID/player?game_url=https%3A%2F%2Flocalhost%3A8080

Remote Test
https://m.facebook.com/instantgames/play/APP_ID/?source=www_play_url

Release:
https://developers.facebook.com/docs/games/instant-games/test-publish-share
1. Zip package
2. App/Instant game/web hosting/Upload
3. Link of Game: https://fb.gg/play/app_id_or_namespace


https://github.com/plexonic/InstantGameDemo

Policy
https://developers.facebook.com/policy/#games

Ads:
https://www.facebook.com/fbgaminghome/blog/install-ads-for-instant-games-best-practices
https://developers.facebook.com/docs/games/gamesonfacebook/monetization
http://phaser.io/tutorials/facebook-instant-games-ads

Share:
https://developers.facebook.com/docs/sharing/webmasters
https://github.com/mrmop/IGX/wiki/Social-Sharing

https://stackoverflow.com/questions/53030470/fbinstant-shareasync-function-doesnt-work-without-any-errors-in-facebook-inst

- share via ShareAsync with out popup

var img = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAASwAAACoCAMAAABt9SM9AAAAulBMVEUAAAAA/wAAAgAAAAMNnQ0AAAIDAAUNiA8GKAYAAAUO8BAJ/QgJ+goKKgkGLAcJugsNcA8LfQsSqxIKagwIFAgU1xUIrAgFAAk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nT9g71+d+9cjZNpvG++mVjmDvjKvQvFQl5b6vVcldNj4dHi7MVPr7D97j3IXq0Q9rJfrcjnlESrPK48RPxrya7t9fPyb4f1N+M2jrNC0ZX9VXu/5SBFCobdmazjv5TxNJDppPDL9le5wkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADA/5f/AOmBdzOElsTMAAAAAElFTkSuQmCC";
FBInstant.shareAsync({
     intent: 'INVITE',
     image: img, // base64Image code must be passed in img
     text: 'Play this Awesome game',
     data: {myReplayData: '...'},
}).then(function() {
     location.reload(); 
});

Leader Board
https://www.emanueleferonato.com/2018/05/18/my-first-facebook-instant-game-has-been-released-play-risky-steps-on-facebook-and-learn-how-to-build-your-own-game/

How to get acces token
https://developers.facebook.com/tools/explorer
https://elfsight.com/blog/2017/10/how-to-get-facebook-access-token/


Reference:
https://static.nrk.no/origo/latest/index.html?icons.md
https://www.youtube.com/playlist?list=PLFfAvp9Vrt0XRu4In4uYowL1efYLTSTpM
https://developers.facebook.com/docs/games/instant-games/getting-started/quickstart
https://phaser.io/tutorials/getting-started-phaser3
https://github.com/Mohammedcha/FB-Instant-Games-ADS-Controller
https://developers.facebook.com/docs/games/instant-games/guides/ads-monetization

Select Context
https://github.com/anisurrahmansagor/Test-Your-Luck/blob/master/index.html
https://github.com/dangkyokhoang/randomness
https://github.com/MJarolimek/tic-tac-toe/tree/master/tic-tac-toe

Sample
https://www.emanueleferonato.com/2018/11/30/match-3-bejeweled-html5-prototype-built-with-phaser-updated-to-phaser-3-adding-object-pooling-and-using-ecma-script-6-conventions/
https://www.emanueleferonato.com/tag/wheel-of-fortune/
https://www.emanueleferonato.com/tag/bejeweled/

0 comments:

Post a Comment