{"metadata":{"image":[],"title":"","description":""},"api":{"url":"","auth":"required","results":{"codes":[]},"settings":"","params":[]},"next":{"description":"","pages":[]},"title":"Starting a game","type":"basic","slug":"starting-a-game","excerpt":"","body":"To launch Spigo games from a proprietary site, a partner needs to complete the following:\n\n  * API Integration. Communicating with the Spigo API. This enables the partner’s players to log in to the SPIGO® Platform and Spigo to buy games using the partner wallet.\n  * GameHub Integration. Using the spigo_frontend.js Javascript library to open the SPIGO® GameHub from which players can launch games.\n\nThis document assumes API integration has been completed and focuses on opening the SPIGO® GameHub.\n\nTo open the SPIGO® GameHub the first thing needed is to import the remotely sourced javascript file [https://staginggames.spigo.com/javascript/spigo-1.0.0.js](https://staginggames.spigo.com/javascript/spigo-1.0.0.js). The files exposed the \"spigo\" object. Calling spigo.openGameWindow the SPIGO® GameHub will be opened in a new window/tab and players are logged into the SPIGO® Platform through communication with the Spigo backend. Please examine the figure below, which shows the interplay among the different components.\n\n\n[block:image]\n{\n  \"images\": [\n    {\n      \"image\": [\n        \"https://files.readme.io/nN3jzmUTOiGXgVfLzDJe_gamehub%20flow.PNG\",\n        \"gamehub flow.PNG\",\n        \"777\",\n        \"537\",\n        \"#41b22e\",\n        \"\"\n      ],\n      \"caption\": \"Communication flow from the GameHub to the partner backend.\"\n    }\n  ]\n}\n[/block]\nThe SPIGO® GameHub, which acts as a common interface for all SPIGO® Platform games. Prior to starting games, the user needs to be logged into the SPIGO® Platform. This is done by opening the GameHub passing along a sessionIdentifier and a playerPartnerIdentifier. The sessionIdentifier must be a session ID associated with the player’s current login on the partner platform and be a maximum of 50 characters. The playerPartnerIdentifier is a unique ID, identifying the player to Spigo. It could be the partner’s internal identifier of said player. Given these two parameters, the Spigo backend will send an isPlayerLoggedIn request through the API and await a response. The partner should only confirm if the player is logged in and has the supplied session identifier. If the partner confirms, the GameHub is loaded. The sessionId supplied to the GameHub can be made invalid by the partner later, by sending a playerLogout message (e.g. if the player does indeed log out of the partner site).\n\n\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"spigo.openGameWindow(siteId, playerPartnerIdentifier, gameId, sessionId, alias, currencyISO4217, localeISO639_ISO3166, useStaging, sourceImageUrl)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nIf you do not wish to open the gameHub in a new window another method called spigo.getGamehubUrl is available. This method takes the same parameters as openGameWindow but will instead return the url to the gameHub and let you easily open it within your own page. E.g. in an iframe. An example of doing this is shown below after the parameters table.\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"spigo.getGamehubUrl(siteId, playerPartnerIdentifier, gameId, sessionId, alias, currencyISO4217, localeISO639_ISO3166, useStaging, sourceImageUrl)\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\n**Parameters** \n[block:parameters]\n{\n  \"data\": {\n    \"1-0\": \"playerPartnerIdentifier\",\n    \"1-1\": \"A partner’s unique identifier for a player. Can never change. Each time a new playerPartnerIdentifier is encountered a new player is created in the Spigo backend.\",\n    \"3-0\": \"sessionId\",\n    \"3-1\": \"A temporary identifier allowing the player to login to the SPIGO® GameHub. Lasts until it times out after 30 minutes of inactivity or until a playerLogout message is sent.\",\n    \"h-0\": \"\",\n    \"0-0\": \"siteId\",\n    \"0-1\": \"The id of the partner's site. Some partners have more than one site and each has it's own id. Note that the siteId may be different in production than on staging.\",\n    \"2-0\": \"GameId\",\n    \"2-1\": \"The Id of the game. A list of all game's ids can be found later in this document.\",\n    \"4-0\": \"alias\",\n    \"5-0\": \"currencyISO4217\",\n    \"6-0\": \"localeISO639_ISO3166\",\n    \"7-0\": \"useStaging\",\n    \"8-0\": \"sourceImageUrl\",\n    \"7-1\": \"true or false, designates whether we are connecting to the staging backend.\",\n    \"8-1\": \"A url to the player's profile image. If not used the player will be shown with a random default image.\",\n    \"6-1\": \"The player's locale. if not set the site's default culture will be used.\\n**Note: should be defined as da-DK, not da_DK.** \",\n    \"5-1\": \"The player's currency. if not set the partner's default currency will be used.\",\n    \"4-1\": \"The player's alias. Used when showing the player in the GameHub and games.\"\n  },\n  \"cols\": 2,\n  \"rows\": 9\n}\n[/block]\nProviding an image url to the player's profile image will allow that image to be shown in the GameHub and games. There are a series of constrains to which the image must adhere:\n\n  * Accepted filetypes: The image must be either gif, jpg, jpeg and png\n  * Timeout: The image must be loaded within 1000 ms\n  * Maximum filesize: The image file must be no larger than 500 kb\n  * Minimum imagesize: The image must be no smaller than 48 x 48 pixels.\n\nIf any of these conditions are not met the image will not be loaded. The player will still be able to load the GameHub and play games.\n\nIn the following we will examine an fictitious example of the information passed through the system when opening the GameHub.\n\nIn this case we want the game to open in an iframe on the partner site. First we define the iframe.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"<iframe id=\\\"spigoIframe\\\" width=\\\"1200\\\" height=\\\"640\\\">\",\n      \"language\": \"html\"\n    }\n  ]\n}\n[/block]\nThen the JavaScript to get the GameHub url is called when the player selects the game on the website. The src of the iframe is set to the url of the gamehub.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"var gamehubUrl = spigo.getGamehubUrl(57, \\\"123456-FF\\\", 42, \\\"09b87487-ffc6-4ca8-8aa6-9b1815c080ac\\\", \\\"paulSmith\\\", GBP, en-GB, false, \\\"http://partnerfiles.com/users/123456-FF/profilePic.png\\\");\\ndocument.getElementById('spigoIframe').src = gamehubUrl;\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nNext the Spigo backend checks login through API.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n   \\\"isPlayerLoggedIn\\\": {\\n      \\\"playerPartnerIdentifier\\\": \\\"123456-FF\\\",\\n      \\\"sessionIdentifier\\\": \\\"09b87487-ffc6-4ca8-8aa6-9b1815c080ac\\\",\\n   }\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nAfther this the partner responds through the API.\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"{\\n    \\\"success\\\": true\\n}\",\n      \"language\": \"json\"\n    }\n  ]\n}\n[/block]\nIn this example, the GameHub is opened with the Yatzy game, English language, using Great British Pounds (£) currency. The player will now be able to enjoy Yatzy, along with thousands of other users.\n\nNote that the GameHub is opened in a new window or tab in the case of mobile devices.\n\n\n**Game Ids**\n[block:parameters]\n{\n  \"data\": {\n    \"0-0\": \"7 Solitaire\",\n    \"1-0\": \"Freecell\",\n    \"2-0\": \"Spider Solitaire\",\n    \"6-0\": \"Tropicana\",\n    \"7-0\": \"Zoo\",\n    \"12-0\": \"Yatzy\",\n    \"14-0\": \"Backgammon\",\n    \"15-0\": \"Hearts\",\n    \"0-1\": \"34\",\n    \"1-1\": \"41\",\n    \"2-1\": \"42\",\n    \"6-1\": \"43\",\n    \"7-1\": \"45\",\n    \"12-1\": \"22\",\n    \"14-1\": \"38\",\n    \"15-1\": \"40\",\n    \"h-0\": \"Game name\",\n    \"h-1\": \"Game Id\",\n    \"h-2\": \"Game Type\",\n    \"0-2\": \"Singleplayer\",\n    \"1-2\": \"Singleplayer\",\n    \"2-2\": \"Singleplayer\",\n    \"6-2\": \"Slot machine\",\n    \"7-2\": \"Slot machine\",\n    \"12-2\": \"Multiplayer\",\n    \"14-2\": \"Multiplayer\",\n    \"15-2\": \"Multiplayer\",\n    \"3-0\": \"Diamonds\",\n    \"3-1\": \"44\",\n    \"3-2\": \"Singleplayer\",\n    \"8-0\": \"Fruits\",\n    \"8-1\": \"47\",\n    \"8-2\": \"Slot machine\",\n    \"13-0\": \"Ludo\",\n    \"13-1\": \"33\",\n    \"13-2\": \"Multiplayer\",\n    \"10-0\": \"Starlight\",\n    \"11-0\": \"Showers\",\n    \"10-1\": \"55\",\n    \"11-1\": \"56\",\n    \"10-2\": \"Slot machine\",\n    \"11-2\": \"Slot machine\",\n    \"5-0\": \"Tivoli\",\n    \"5-1\": \"36\",\n    \"5-2\": \"Slot machine\",\n    \"4-0\": \"Yukon 21\",\n    \"4-1\": \"58\",\n    \"4-2\": \"Singleplayer\",\n    \"9-0\": \"Hattrick\",\n    \"9-1\": \"49\",\n    \"9-2\": \"Slot machine\"\n  },\n  \"cols\": 3,\n  \"rows\": 16\n}\n[/block]","updates":[],"order":5,"isReference":false,"hidden":false,"sync_unique":"","link_url":"","link_external":false,"_id":"5a55b149f85c3a0032f10e63","category":{"sync":{"isSync":false,"url":""},"pages":[],"title":"Documentation","slug":"documentation","order":0,"from_sync":false,"reference":false,"_id":"5a55b149f85c3a0032f10e56","version":"5a55b149f85c3a0032f10e55","project":"550dd1756c0b4c0d00fd436e","createdAt":"2015-03-21T20:15:50.122Z","__v":0},"project":"550dd1756c0b4c0d00fd436e","parentDoc":null,"user":"5514315e67d97f2500b774ed","version":{"version":"1.5","version_clean":"1.5.0","codename":"","is_stable":true,"is_beta":false,"is_hidden":false,"is_deprecated":false,"categories":["5a55b149f85c3a0032f10e56","5a55b149f85c3a0032f10e57","5a55b149f85c3a0032f10e58","5a55b149f85c3a0032f10e59","5a55b149f85c3a0032f10e5a","5a55b149f85c3a0032f10e5b","5a55b149f85c3a0032f10e5c","5a55b149f85c3a0032f10e5d","5d1da68fa911a50226595581"],"_id":"5a55b149f85c3a0032f10e55","project":"550dd1756c0b4c0d00fd436e","createdAt":"2018-01-10T06:23:05.406Z","releaseDate":"2018-01-10T06:23:05.406Z","__v":2},"createdAt":"2016-06-13T09:23:13.768Z","githubsync":"","__v":0}
To launch Spigo games from a proprietary site, a partner needs to complete the following: * API Integration. Communicating with the Spigo API. This enables the partner’s players to log in to the SPIGO® Platform and Spigo to buy games using the partner wallet. * GameHub Integration. Using the spigo_frontend.js Javascript library to open the SPIGO® GameHub from which players can launch games. This document assumes API integration has been completed and focuses on opening the SPIGO® GameHub. To open the SPIGO® GameHub the first thing needed is to import the remotely sourced javascript file [https://staginggames.spigo.com/javascript/spigo-1.0.0.js](https://staginggames.spigo.com/javascript/spigo-1.0.0.js). The files exposed the "spigo" object. Calling spigo.openGameWindow the SPIGO® GameHub will be opened in a new window/tab and players are logged into the SPIGO® Platform through communication with the Spigo backend. Please examine the figure below, which shows the interplay among the different components. [block:image] { "images": [ { "image": [ "https://files.readme.io/nN3jzmUTOiGXgVfLzDJe_gamehub%20flow.PNG", "gamehub flow.PNG", "777", "537", "#41b22e", "" ], "caption": "Communication flow from the GameHub to the partner backend." } ] } [/block] The SPIGO® GameHub, which acts as a common interface for all SPIGO® Platform games. Prior to starting games, the user needs to be logged into the SPIGO® Platform. This is done by opening the GameHub passing along a sessionIdentifier and a playerPartnerIdentifier. The sessionIdentifier must be a session ID associated with the player’s current login on the partner platform and be a maximum of 50 characters. The playerPartnerIdentifier is a unique ID, identifying the player to Spigo. It could be the partner’s internal identifier of said player. Given these two parameters, the Spigo backend will send an isPlayerLoggedIn request through the API and await a response. The partner should only confirm if the player is logged in and has the supplied session identifier. If the partner confirms, the GameHub is loaded. The sessionId supplied to the GameHub can be made invalid by the partner later, by sending a playerLogout message (e.g. if the player does indeed log out of the partner site). [block:code] { "codes": [ { "code": "spigo.openGameWindow(siteId, playerPartnerIdentifier, gameId, sessionId, alias, currencyISO4217, localeISO639_ISO3166, useStaging, sourceImageUrl)", "language": "javascript" } ] } [/block] If you do not wish to open the gameHub in a new window another method called spigo.getGamehubUrl is available. This method takes the same parameters as openGameWindow but will instead return the url to the gameHub and let you easily open it within your own page. E.g. in an iframe. An example of doing this is shown below after the parameters table. [block:code] { "codes": [ { "code": "spigo.getGamehubUrl(siteId, playerPartnerIdentifier, gameId, sessionId, alias, currencyISO4217, localeISO639_ISO3166, useStaging, sourceImageUrl)", "language": "javascript" } ] } [/block] **Parameters** [block:parameters] { "data": { "1-0": "playerPartnerIdentifier", "1-1": "A partner’s unique identifier for a player. Can never change. Each time a new playerPartnerIdentifier is encountered a new player is created in the Spigo backend.", "3-0": "sessionId", "3-1": "A temporary identifier allowing the player to login to the SPIGO® GameHub. Lasts until it times out after 30 minutes of inactivity or until a playerLogout message is sent.", "h-0": "", "0-0": "siteId", "0-1": "The id of the partner's site. Some partners have more than one site and each has it's own id. Note that the siteId may be different in production than on staging.", "2-0": "GameId", "2-1": "The Id of the game. A list of all game's ids can be found later in this document.", "4-0": "alias", "5-0": "currencyISO4217", "6-0": "localeISO639_ISO3166", "7-0": "useStaging", "8-0": "sourceImageUrl", "7-1": "true or false, designates whether we are connecting to the staging backend.", "8-1": "A url to the player's profile image. If not used the player will be shown with a random default image.", "6-1": "The player's locale. if not set the site's default culture will be used.\n**Note: should be defined as da-DK, not da_DK.** ", "5-1": "The player's currency. if not set the partner's default currency will be used.", "4-1": "The player's alias. Used when showing the player in the GameHub and games." }, "cols": 2, "rows": 9 } [/block] Providing an image url to the player's profile image will allow that image to be shown in the GameHub and games. There are a series of constrains to which the image must adhere: * Accepted filetypes: The image must be either gif, jpg, jpeg and png * Timeout: The image must be loaded within 1000 ms * Maximum filesize: The image file must be no larger than 500 kb * Minimum imagesize: The image must be no smaller than 48 x 48 pixels. If any of these conditions are not met the image will not be loaded. The player will still be able to load the GameHub and play games. In the following we will examine an fictitious example of the information passed through the system when opening the GameHub. In this case we want the game to open in an iframe on the partner site. First we define the iframe. [block:code] { "codes": [ { "code": "<iframe id=\"spigoIframe\" width=\"1200\" height=\"640\">", "language": "html" } ] } [/block] Then the JavaScript to get the GameHub url is called when the player selects the game on the website. The src of the iframe is set to the url of the gamehub. [block:code] { "codes": [ { "code": "var gamehubUrl = spigo.getGamehubUrl(57, \"123456-FF\", 42, \"09b87487-ffc6-4ca8-8aa6-9b1815c080ac\", \"paulSmith\", GBP, en-GB, false, \"http://partnerfiles.com/users/123456-FF/profilePic.png\");\ndocument.getElementById('spigoIframe').src = gamehubUrl;", "language": "javascript" } ] } [/block] Next the Spigo backend checks login through API. [block:code] { "codes": [ { "code": "{\n \"isPlayerLoggedIn\": {\n \"playerPartnerIdentifier\": \"123456-FF\",\n \"sessionIdentifier\": \"09b87487-ffc6-4ca8-8aa6-9b1815c080ac\",\n }\n}", "language": "json" } ] } [/block] Afther this the partner responds through the API. [block:code] { "codes": [ { "code": "{\n \"success\": true\n}", "language": "json" } ] } [/block] In this example, the GameHub is opened with the Yatzy game, English language, using Great British Pounds (£) currency. The player will now be able to enjoy Yatzy, along with thousands of other users. Note that the GameHub is opened in a new window or tab in the case of mobile devices. **Game Ids** [block:parameters] { "data": { "0-0": "7 Solitaire", "1-0": "Freecell", "2-0": "Spider Solitaire", "6-0": "Tropicana", "7-0": "Zoo", "12-0": "Yatzy", "14-0": "Backgammon", "15-0": "Hearts", "0-1": "34", "1-1": "41", "2-1": "42", "6-1": "43", "7-1": "45", "12-1": "22", "14-1": "38", "15-1": "40", "h-0": "Game name", "h-1": "Game Id", "h-2": "Game Type", "0-2": "Singleplayer", "1-2": "Singleplayer", "2-2": "Singleplayer", "6-2": "Slot machine", "7-2": "Slot machine", "12-2": "Multiplayer", "14-2": "Multiplayer", "15-2": "Multiplayer", "3-0": "Diamonds", "3-1": "44", "3-2": "Singleplayer", "8-0": "Fruits", "8-1": "47", "8-2": "Slot machine", "13-0": "Ludo", "13-1": "33", "13-2": "Multiplayer", "10-0": "Starlight", "11-0": "Showers", "10-1": "55", "11-1": "56", "10-2": "Slot machine", "11-2": "Slot machine", "5-0": "Tivoli", "5-1": "36", "5-2": "Slot machine", "4-0": "Yukon 21", "4-1": "58", "4-2": "Singleplayer", "9-0": "Hattrick", "9-1": "49", "9-2": "Slot machine" }, "cols": 3, "rows": 16 } [/block]