Battlelog API Update

It looks like Battlelog has gone public and there are already a number of servers up and running. Unfortunately, the game does not unlock here for another 10 hours or so.

It seems EA updated the authentication system slightly. This caused the API to not get proper credentials when logging into Battlelog. Fortunately, the fix was relatively painless. The image locations on the Battlelog CDN have also changed slightly, and those helper methods have been updated accordingly.

This is simply a bugfix release, but I plan to explore Co-op and other additions to the API when I actually have access to Battlefield 3. (Oh looky, longest headshot is actually being recorded now!)

Head over to the project page to see the specifics and download the updated API.

POSTED October 24, 2011 UNDER Projects

Comments

MrO1nk said on October 24, 2011 at 4:22 pm:

Error on line 279 and further, seems like it has something to do with
‘rank’ => $data['overviewStats']['rank']?:0,

the ?:0

    Blake said on October 24, 2011 at 6:06 pm:

    What version of PHP are you running? Additionally, could you give my any soldier IDs that are having this problem?
    Seems to be working fine on my end.

MrO1nk said on October 24, 2011 at 6:51 pm:

php 5

Parse error: syntax error, unexpected ‘:’ in /home/w1111460/domains/crab-studio.eu/public_html/battlelog/BattlelogApi.inc.php on line 279

is the error i get, just for trying to print a name of a soldier.

MrO1nk said on October 24, 2011 at 6:51 pm:

oh and the soldier id is : 351108798

Artax said on October 24, 2011 at 6:58 pm:

I’m having the same issue, I’m running a fresh install of PHP 5.2. I was able to fix this by changing “?:0″ to “?0:0″.

Another problem I’ve had with PHP 5.2 is with the DateTime class, specifically the setTimeStamp method, it does not exist in 5.2, only 5.3 or newer.

Even with both of those problems worked around, I still get an error:
Fatal error: Uncaught exception ‘Exception’ with message ‘Invalid soldier data’ in /usr/home/stats.bfclanwars.com/BattlelogApi.inc.php:262
Stack trace:
#0 /usr/home/stats.bfclanwars.com/BattlelogApi.inc.php(244): BF3Soldier->_parseData(”)
#1 /usr/home/stats.bfclanwars.com/BattlelogApi.inc.php(110): BF3Soldier->__construct(Object(BattlelogApi), ”)
#2 /usr/home/stats.bfclanwars.com/index.php(23): BattlelogApi->getBF3Soldier(’240578476′)
#3 {main}
thrown in /usr/home/stats.bfclanwars.com/BattlelogApi.inc.php on line 262

It looks like the data is null, but this is an active user with stats and I can get their raw stats no problem from:
http://battlelog.battlefield.com/bf3/overviewPopulateStats/240578476/None/1/

BTW, thanks for throwing together the API!

Artax

Blake said on October 24, 2011 at 7:21 pm:

Looks like all of those problems are being caused by PHP <5.3. You guys need to update your PHP versions ;)

Anyway, I’ve fixed most of problems you listed but all of my servers are running PHP 5.3.x, so I can’t test whether or not they will actually help you guys…
I’ll post the update here in a sec; let me know if it fixes things.
(@Atrix, your fix will make all the variables equal 0.)

sasser said on December 2, 2011 at 5:54 pm:

Nice Work

Leave a Reply

Fields marked with an asterisk (*) are required.