Page 1 of 1

BF3 online stats block

Posted: 21. May 2013 14:17
by DND
Your Portal Version: 2.0.1
Your phpBB Type: Standard phpBB3
MODs installed: Yes
Your knowledge: Beginner

What have you done before the problem was there?


What have you already tryed to solve the problem?


Description and Message
what I am trying to do is add a Battlefield 3 Online Stats block like the one on this vBulletin forum http://www.global-gamers.net/
I have the same PHP file as they have used on that site, the code from that file is below

Code: Select all

<?php
// Run POST Request via CURL
$c=curl_init('http://api.bf3stats.com/global/onlinestats/');
curl_setopt($c,CURLOPT_HEADER,false);
curl_setopt($c,CURLOPT_POST,true);
curl_setopt($c,CURLOPT_USERAGENT,'BF3StatsAPI/0.1');
curl_setopt($c,CURLOPT_HTTPHEADER,array('Expect:'));
curl_setopt($c,CURLOPT_RETURNTRANSFER,true);
curl_setopt($c,CURLOPT_POSTFIELDS,$postdata);
$data=curl_exec($c);
$statuscode=curl_getinfo($c,CURLINFO_HTTP_CODE);
curl_close($c);
if($statuscode==200){
// Decode JSON Data
$data=json_decode($data,true);
$html_out = '<table>';
if (isset($data['pc'])){ $html_out .= '<tr><td align="right" style="color:#EFEFEF;font-weight:bold;">PC Players: </td> <td style="color:#FF9900;font-weight:bold;">'.number_format($data['pc']).'</td></tr>'; }
if (isset($data['ps3'])){ $html_out .= '<tr><td align="right" style="color:#EFEFEF;font-weight:bold;">PS3 Players: </td> <td style="color:#FF9900;font-weight:bold;">'.number_format($data['ps3']).'</td></tr>'; }
if (isset($data['360'])){ $html_out .= '<tr><td align="right" style="color:#EFEFEF;font-weight:bold;">XBox360 Players: </td> <td style="color:#FF9900;font-weight:bold;">'.number_format($data['360']).'</td></tr>'; }
$html_out .= '</table>';
echo $html_out;
}else{
echo "BF3 Stats API error status: ".$statuscode;
}
?>
Is there a way to get this to work in a Board3 Portal block ?[/i]

Re: BF3 online stats block

Posted: 21. May 2013 16:54
by Kirk
You must create a new module.
Look at this guide: How to edit a module file

Re: BF3 online stats block

Posted: 21. May 2013 17:46
by DND
Thanx mate but that link just opens a reply page to this topic

Re: BF3 online stats block

Posted: 21. May 2013 18:07
by Kirk
Sorry, I've corrected the link, Thanks for the note. :)

Re: BF3 online stats block

Posted: 22. May 2013 03:52
by DND
thanks again,,

I'm following the "How to edit a module file" but I'm not sure where I need to add the code from my first post into it,

Re: BF3 online stats block

Posted: 22. May 2013 09:04
by Kirk
As an example portal_custom.php
Paste your code after global $ config, $ template, $ portal_config, $ user, without a <?php at the beginning and without ?> At the end, this is already predetermined.
Note, this guidance: How to create a module zip for Board3 Portal