Giter VIP home page Giter VIP logo

Comments (5)

subsoap avatar subsoap commented on May 26, 2024 1

There is a "mock" api included in the example https://origincache.facebook.com/developers/resources/?id=tic-tac-toe.zip
fbinstant.6.0.mock.js.txt

It returns dummy values to all function calls. Could detect if the domain is localhost, and then load the dummy api instead. That way building Instant Game apps with Defold would be easier doing Project -> Build HTML in the editor.

from extension-fbinstant.

britzl avatar britzl commented on May 26, 2024

Do you have some more information about this?

from extension-fbinstant.

britzl avatar britzl commented on May 26, 2024

Ah, I see. Ok, so that mocks the fbinstant js api. That might be useful.

I actually also provide a mock version of the fbinstant.* namespace for rapid testing on desktop, without the need to build/bundle to HTML5. It's a pure-Lua implementation of the fbinstant.* functions with static responses (no backend or anything like that involved). I'm not sure if I want to document it since I'm not sure of its usefulness yet. The mock version is in fbinstant.utils.mock.lua. require() it in a main/loader script before calling any fbinstant functions and give it some dummy data about the player(s) and context:

-- mock fbinstant.* to test your game without the need to build/bundle for HTML5
require "fbinstant.utils.mock"
-- this will be true on non HTML5 builds
if fbinstant.mock then
	-- this is the logged in player
	fbinstant.PLAYER = {
		name = "Player 1",
		id = "100000000001fake",
		photo = "http://i.pravatar.cc/200?u=123",
		locale = "en_US",
	}

	-- these are the players in the current context (fbinstant.get_players())
	fbinstant.PLAYERS = {
		fbinstant.PLAYER,
		{
			name = "Player 2",
			id = "100000000002fake",
			photo = "http://i.pravatar.cc/200?u=456",
			locale = "en_US",
		}
	}

	-- the current context
	fbinstant.CONTEXT = {
		id = "123456fake",
		type = fbinstant.CONTEXT_THREAD,
		size = 2,
	}
end

from extension-fbinstant.

subsoap avatar subsoap commented on May 26, 2024

Desktop builds are faster than HTML5 so it would be useful too. The problem I see is needing to update so many things as the API changes.

I'm going to go all in on making some big Facebook Instant Games (and port some in progress projects to it) so anything to help productivity will be useful and I bet others will appreciate it too!

Another thing which may be useful would be a chrome extension or js include which can detect new builds somehow and autoreload the web page... I've used something like that with other tools before. Another way to do it would be to make the build script open a fresh page but have a for example Chrome extension auto close other tabs of the specified name...

from extension-fbinstant.

britzl avatar britzl commented on May 26, 2024

I can't imagine that Facebook would make many API changes now that the API is public. Sure, they may deprecate functions and add new ones, but the ones that are documented now are not likely to change.

It would be quite useful if Facebook provided this mock API somewhere more accessible, instead of hidden away inside a zip. Or if they provided an API definition in a parsable format so that something like my mock.lua file could be autogenerated much in the same way as Amazon provides API definitions for the AWS SDK.

from extension-fbinstant.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.