maartenstaa/gameanalytics-php

PHP wrapper for the GameAnalytics REST API.

v2.0 2016-02-23 20:08 UTC

This package is auto-updated.

Last update: 2024-04-04 22:03:17 UTC


README

PHP wrapper for the GameAnalytics REST API.

Build Status Scrutinizer Code Quality Code Coverage

Installation

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.

Usage

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();

Contributing

Coding standard

All code is to follow the PSR-2 coding standard.

Unit tests

If you find a bug, feel free to send a pull request to fix it, but make sure to always include a regression test.