This library provides functionality for easily and quickly accessing the BinaryBeast API Services
Unlike the previous versions, the 3.0.0+ version of this library is now Object-oriented
There are two things you need to do before you start developing:
You can find your api_key from your user settings at binarybeast.com http://binarybeast.com/user/settings/api
The values in BBConfiguration.php allow you to define your api_key, setup local response caching, and even extend model classes
Note: This will not affect users currently supplying an api_key to the BinaryBeast, constructor still accepts an api_key value
Thanks to BBLegacy.php, your code will NOT break if you upgrade to the latest library version
In order to cut down on the number of API calls your application needs to make, this library provides integrated response caching through the BBCache class
However in order to take advantage of this, you must define your database connection details in BBConfiguration
You can view a full log of your recent API activity, including what arguments were sent, and how the API responded here: http://binarybeast.com/user/settings/api_history
require('BinaryBeast.php');
$bb = new BinaryBeast();
$tournament = $bb->tournament();
$tournament->title = 'My new tournament!';
if($tournament->save()) {
echo '<a href="' . $tournament->url . '">Tournament Created Successfully!</a>';
}
else {
var_dump($bb->last_error);
}
require('BinaryBeast.php');
$bb = new BinaryBeast();
$tournament = $bb->tournament('my_tournament_id');
if(sizeof($tournament->open_matches()) > 0) {
$match = $tournament->open_matches[0];
$match->set_winner($match->team2());
if($match->report()) {
echo $match->winner() . ' defeated ' . $match->loser() . ' in match ' . $match->id;
}
else {
var_dump($bb->last_error);
}
}
Using BBHelper
require('BinaryBeast.php');
$bb = new BinaryBeast();
BBHelper::embed_tournament_groups('my_tournament_id');
Using BBTournament
require('BinaryBeast.php');
$bb = new BinaryBeast();
$tournament = $bb->tournament('my_tournament_id');
$tournament->embed();
$maps = $bb->map->game_list('SC2');
foreach($maps as $map) {
echo $map->map . ' (' . $map->map_id . ') <br />';
}
$races = $bb->race->game_list('SC2');
foreach($races as $race) {
echo '<img src="' . $race->race_icon . '" /> ' . $race->race . ' (' . $race->race_id . ') <br />';
}
Coming soon
-
Adds
BBMap::Load()
- Allows loading a map by map_id
-
Adds support for the new tournament map_pool services
$tournament->map_pool
to fetch the map pool$tournament->add_map()
to add a map$tournament->remove_map()
to remove a map-
- Version 3.1.8 (2013-07-01)
-
Adds
$tournament->played_matches($freewins = false, $stream = false)
- Returns array of recently reported BBMatch objects
- Set
$stream = true
and it will only return each match result once
- Set
- Returns array of recently reported BBMatch objects
- Fixes a bug in BBTournament that was causing fatal PHP errors after saving a new tournament with teams already added
- Restructured the way BBTeam stores and filters BBTeam arrays to resolve bugs caused by stale cached results
- Adds
$tournament->freewins
and$tournament->freewins()
for returning freewin team objects
-
result
table for api cache is now created as longtext -
BBDev
now extracts data before dumping objects (to avoid fatal serialization errors) -
save()
anddelete()
now clear list and id cache- Resolves issue of stale list results
-
Model list results now honor custom classes defined in
BBConfiguration
-
New method:
$tournament->count()
- Returns the total number of tournaments created by your account
-
$team->notes
now automatically automatically encoded and decoded as json\ -
$tournament->teams()
now returns FreeWins if you set the 3rd parameter ($freewins
) totrue
-
Adds
BBSimpleModel::SERVICE_LIST
for consistency -
- $tournament->hidden is now automatically automatically encoded and decoded as json
-
Adds
$bb->config
magic property- Returns the current configuration object (
BBConfiguration
)
- Returns the current configuration object (
-
Adds
$bb->tournament->on_create('url here')
callback- Triggered when tournaments are created the account associated with the api_key
-
Adds
BBCache::TTL_*
constants, simple TTL values for certain time periods- For example,
BBCache::TTL_WEEK
can be used to cache an API response for 1 week
- For example,
See the change log for more
These were just a few quick examples, visit BinaryBeast.com for more examples, and full documentation of the library
Public development and issue tracking is available through our public trello board thatfor