You can use the API of this server to create your own client, it is not important which language you use, you just have to make sure you use the HTTP-API, which should be possible in nearly all programming languages.
With each request you have to provide the API-Version you want to use. Currently this is 1.0. You have to add
this version information to each API call by adding /version/1.0 to the URL.
Currently the API returns only JSON results, with each call you have to tell the server which format you prefer.
You can do this by adding /format/json to the URL.
Example Request from Javascript (used in the online client):
var jsonRequest = new Request.JSON({ url: 'http://fourinaline.phpgangsta.de/game/getavailableenemies/version/1.0/format/json', onSuccess: function(responseJSON){ $('enemyId').empty(); Array.each(responseJSON.enemies, function(item) { var option = new Element('option', {value: item.enemyId, text: item.name}); option.inject($('enemyId')); }); } }).send();
Here is the list of all available API calls you can use:
-
Request: http://fourinaline.phpgangsta.de/game/getavailableenemies
Response: {"enemies":[{"enemyId":"1","name":"Rudi Random"}]}
-
Request: http://fourinaline.phpgangsta.de/game/create
Parameters (can be GET or POST):
name The player name enemyId The enemy you want to play against. Check getavailableenemies call width Optional; Width of the grid, has to be between 5 and 20 (defaults to 7) height Optional; Height of the grid, has to be between 4 and 12 (defaults to 6) Response: {"playerId":"24","gameId":"11","playerNumber":1,"token":"7ade4d29ab5cab7c0297d79f135008e0"}
-
Request: http://fourinaline.phpgangsta.de/game/getinstruction
Parameters (can be GET or POST):
gameId The game ID playerId Your player ID token The token you got in the create call. This is like a password Response: {"instruction":"MOVE","grid":[[null,null,null,null,null,null],[null,null,null,null,null,null],[null,null,null,null,null,null],[null,null,null,null,null,null],[null,null,null,null,null,null],[null,null,null,null,null,null],[null,null,null,null,null,null]]}
MOVE: You are the next player, you should call /game/move next.
END: There is a winner, the game is finished
NOOP: Please wait, do nothing, the other player is currently doing his move. Call getinstruction again in a few seconds. -
Request: http://fourinaline.phpgangsta.de/game/move
Parameters (can be GET or POST):
gameId The game ID playerId Your player ID column The column you want to put your disc into token The token you got in the create call. This is like a password Response: {"grid":[[null,null,null,null,null,null],[1,null,null,null,null,null],[null,null,null,null,null,null],[null,null,null,null,null,null],[null,null,null,null,null,null],[null,null,null,null,null,null],[null,null,null,null,null,null]]}