I figured it out. For anyone else looking to do the same thing.
- I installed XAMPP to set up a server that runs locally at http://localhost.
- I then created a PHP script that read a $_POST['username'] array variable to extract all of the key/value pairs from the HTTP POST from the game.
- From the Cocos2dx game I used the HTTPClient library to created a HTTP Request
- The Request data contained a string with a key/value pair so that the PHP script could read it on the server.
-
The string looked like this:
'username=damorton&score=playerScore'
Send the request from the game using request->send(data); and specify http://localhost as the target.
-
The PHP script can then identify the keys username and score by referencing its name in the array variable :
$name = $_POST['username']
$score = $_POST['score']
From here I just connected to a local MySQL database that I set up in XAMPP. Create some SQL queries in the PHP scripts for reading and writing the values stored in $name and $score. All communication with the database happens in the PHP scripts. The game interfaces with the PHP on the server to read and write to the database. And that was it.
I have since moved the local server to a remote one by copying the PHP scripts and using the domain name to access the PHP scripts.
http://www.insertyourdomainnamehere.com/update_database.php
The game now uses an online leaderboard, is available on the Windows Store, and will update all of the players stats remotely.
Hope this helps someone out :)