PHP wrapper for the GameAnalytics REST API.
Using Composer, add the package to your require
section.
{
"require": {
"maartenstaa/gameanalytics-php": "~2"
}
}
This package requires you to select an HTTP client to be used. For more information, read the documentation.
First, create a client using the game key and associated secret key. The third parameter is the HTTP client you want to use. If you do not provide it, the package will try to auto-detect which one is available. The fourth and final parameter is the HTTP message factory you wish to use. Again, if you do not provide it, the package will try to auto-detect which is available.
use MaartenStaa\GameAnalytics\Client;
$client = new Client($gameKey, $secretKey);
Next, you can use the "init" and "event" functions on the client to get a message instance. Use the set() function to configure the required parameters (refer to the official documentation) and use send() to send the message. You will receive a PSR-7 response object.
$client->init()->set(array(...))->send();
$message = $client->event('user');
$message->set('foo', 'bar')
->set('baz', 'bax')
->send();
All code is to follow the PSR-2 coding standard.
If you find a bug, feel free to send a pull request to fix it, but make sure to always include a regression test.