I made a few quick changes that should help those of you who are running versions of PHP less than 5.3. Specifically, the ternary operator (without the middle parameter) and DateTime::setTimestamp() were causing problems.
Since I don’t have any servers running anything older than PHP 5.3.0, I’ll need you guys to point out any further problem areas. Maybe I’ll see if I can find an old server I can throw PHP 5.2 on for testing.
In the meantime, feel free to head over to the project page and grab the latest copy.
Comments
That worked, thank you.
Artax
Any idea how to get total ribbons? The specific page you’re querying only seems to give ribbon descriptions and not totals. For example, the total number of Flag Attacker Ribbons a player has received.
Thanks
I actually got the answer to my own question and thought I would share it with you. http://www.bfclanwars.com/2011/10/25/bf3-stats-paths-json-format/
I’m having trouble finding ribbon counts and so on in the awards JSON link you posted.
Am I just not seeing it?
Here’s the path for my stats which I just tested:
http://battlelog.battlefield.com/bf3/awardsPopulateStats/335838405/1/
If the JSON has been converted to an array, you should be able to find the ribbon values at:
['data']['awards']['AwardGroup_Ribbons']['43']['actualValue']
That will give you the actual value for the Conquest Winner Ribbon. It’s toward the bottom of all the page when looking at just the JSON code.
Use the IDs at my blog to figure out which Ribbon is which, because they are referenced by ID r##, or r23, something like that.
I looked over all of those numbers earlier today, and they were all zeroed out.
It appears to be working now though.
i found the json for the servers:
http://battlelog.battlefield.com/bf3/servers/show/7a8a3056-4eff-4ce8-a9d0-efa429749358/?json=1
7a8a3056-4eff-4ce8-a9d0-efa429749358 is a server id.
Should be easy to make a server status banner.
could you tell me how i can get the server name out of that file ?
it should be under SERVER_INFO => extendedInfo => name
I cant figure it out under what section it is.
Wow wow. I was doing a little digging into Battlelog, and it turns out given the proper HTTP headers everything is returned as JSON.
Expect a very large update to my API soon (including the data Artax was kind enough to point out).
Nice.. looked a while for that and really like your api, with json data it will be perfect
im running the example and i get this.
Fatal error: Uncaught exception ‘Exception’ with message ‘Invalid soldier data’ in /var/www/framework/BattlelogApi.inc.php:262 Stack trace: #0 /var/www/framework/BattlelogApi.inc.php(244): BF3Soldier->_parseData(”) #1 /var/www/framework/BattlelogApi.inc.php(110): BF3Soldier->__construct(Object(BattlelogApi), ”) #2 /var/www/framework/example.php(6): BattlelogApi->getBF3Soldier(’180351032′) #3 {main} thrown in /var/www/framework/BattlelogApi.inc.php on line 262
I also tried other player_id with data on it but no effect ?
what am i doing wrong here im running on PHP Version 5.3.2 ??
thx in advance
Battlelog was have issues earlier today. Does the problem still persist?
It’s working for me right now. I did have an issue getting started initially because of the cookie that needs to be created in order to save your authentication. Check to see that your cookie is getting created, by default it’s in the same directory that you are running your script from. If you do not see a file called cookies.txt, then your server is not saving the authentication information from Battlelog and you won’t be able to subsequent queries.
If that’s the case then the problem is your webserver doesn’t have access to create the cookie file. A quick way (but probably not the best) to get that working is to change the path to the cookie file and place it in a folder that has full write access to anyone (chmod 777). So on line 33 (i think) change:
define(‘BLA_COOKIE_FILE’, ‘cookies.txt’);
to something like:
define(‘BLA_COOKIE_FILE’, ‘./cookies/cookies.txt’);
where the directory cookies has full write access.
That’s basically what I needed to do in order to get the script working for me.
It all works fine after chown off the folder to webserver use. seems that that was indeed the cookies that where the problem.
thx guys!! good work
I just wanted to say thanks for the api i was creating something like this myself but you saved me a lot of time and effort. So thanks very much.
Leave a Reply