Recently the developers of Final Battleground have made it possible for others to tap in to the FBG data. To make life easier for others looking to use this data in their websites, I have developed a PHP class that allows for easy querying of the FBG API.
Say what now? Well.. To put it simpler, our website connects to the FBG API to collect data. This data for example shows how many plinks a user has and what his or her kills per death are and a whole lot more. Normally it would take quite a bit of effort to gather this data using PHP code, but using this class, you can do it in only two lines of simple code.
Note that the class only gathers the data and returns it to you as an array. Displaying the data on your website is something you have to do yourself and will probably require some PHP skills.
Download You can find a .zip file with the class here:
http://www.livebythegun.com/files/php_fbg_api_v0.2.zip
Usual warnings apply; I am not responsible for any damage this PHP class may do to you or your systems. If it happens to gain self awareness and takes over the world, it's not my problem.
The .zip file contains two files; 'fbg_api.php' and 'fbg_example.php'. The file 'fbg_api.php' contains the FBGAPI class that is used to query the Final Battleground API. You should not have to change anything in this file. Just place it in the directory on your webhosting account that contains the files of your website.
The file 'fbg_example.php' contains an example on how to use the FBGAPI class. The file has a lot of comments in it that should make it pretty easy to understand. If you want to see the example in action, just place it in the same directory as you placed 'fbg_api.php' in and open it in a web browser.
You can also view the example page on our web server: http://www.livebythegun.com/fbg_example.php
Not all FBG data The PHP FBG API class uses the API service provided by Final Battleground. For example, you can see my FBG profile data as provided by the API here: http://api.finalbattleground.com/pub/profile.svc/rest/getdata?game=css&unique=STEAM_0:1:7546864
As you probably know Final Battleground has a wealth of data, ranging from awards, to stats per weapon, to plinks transactions, and so on. Because the FBG developers have to spend time on the development and documentation of the API services they provide, not all this data is available as of yet (and I have no idea what their intentions are with regards to making more things available in the future.) The data that is available through the FBG API at this time is..
- General profile data
- General clan data
- Clan members information
Querying that information is simplified through this PHP class.
Sockets The PHP FBG API class relies on PHP socket functions to connect to the Final Battleground API. Some web hosts disable sockets to avoid abuse, so if you get any error message about sockets, it is likely that this is the case.
If you want to solve this problem, you could ask you webhost to enable the socket functions for you, or you could re-write the class to use something like cURL. If you do that, please share you code with the rest of us.
Questions, errors, complaints Feel free to email or pm me about any problems you run into when using this PHP class. I will do my best to get back to you as soon as possible. Unfortunately I can not help you with integrating the data into your website. That is something you will have to do yourself. If you are not capable of doing so, it might be a good idea to read through some PHP tutorials first.
Many thanks to the FBG team for providing us with the FBG API! |
It is your problem.. if you dont call a AI program based on a battleground website a problem.. then you want to die O_o