gameball / gameball-php
Gameball PHP Library
Installs: 3 764
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
README
The Gameball PHP SDK provides convenient access to the Gameball API from applications written in the PHP language.
Documentation
Please refer to the Gameball API docs.
Requirements
- PHP 5.6.0 and later.
Installation
You don't need this source code unless you want to modify the SDK. If you just want to use the SDK, just run:
Composer
You can install the bindings via Composer. Run the following command:
composer require gameball/gameball-php
To use the bindings, use Composer's autoload:
require_once('vendor/autoload.php');
Dependencies
The bindings require the following extensions in order to work properly:
If you use Composer, these dependencies should be handled automatically. If you install manually, you'll want to make sure that these extensions are available.
Usage
The SDK needs to be configured with your account's API & Transaction keys available in your Gameball Dashboard
Example
Sending an Event
// INITIALIZE PLAYER $gameball = new \Gameball\GameballClient('Your_API_Key', 'Your_SECRET_Key'); $playerAttributes = new \Gameball\Models\PlayerAttributes(); $playerAttributes->displayName = "display_name"; $playerAttributes->firstName = 'first_name'; $playerAttributes->lastName = 'last_name'; $playerAttributes->gender = 'M'; $playerAttributes->email = 'user@example.com'; $playerAttributes->mobile = '_mobile_'; $playerAttributes->dateOfBirth = '1991-09-19T00:00:00.000Z'; $playerAttributes->joinDate = '2022-01-01T21:06:29.158Z'; $playerRequest = \Gameball\Models\PlayerRequest::factory( "player_unique_id", null, // EMAIL null, // MOBILE $playerAttributes ); // SEND EVENT $eventRequest = new \Gameball\Models\EventRequest(); $eventRequest->addEvent('place_order'); $eventRequest->addMetaData('place_order','total_amount','100'); $eventRequest->addMetaData('place_order','category',array("electronics","cosmetics")); $eventRequest->addEvent('review'); $playerRequest = \Gameball\Models\PlayerRequest::factory('player123'); $eventRequest->playerRequest = $playerRequest; $res= $gameball->event->sendEvent($eventRequest); // Accessing response data echo $res->body; // Accessing response data as JSON echo $res->decodedJson;
Handling exceptions
Unsuccessful requests raise exceptions. The raised exception will reflect the sort of error that occurred with appropriate message and error code . Please refer to the Gameball API docs.
Contribution
The master branch of this repository contains the latest stable release of the SDK.
Contact
For usage questions\suggestions drop us an email at support[ at ]gameball.co. Please report any bugs as issues.