Results 1 to 20 of 20
  1. #1
    Member
    Join Date
    2011-11-08
    Location
    NRW
    Posts
    112
    BFBC2 PC
    Tony_GER
    BF3 PC
    xXxT0NYxXx

    API PHP example with table output

    hi guys,
    I have a problem, I do not understand why this code does not loop to lbmember. Is there someone who can explain that to me?
    Demo link:
    http://schulte-solingen.de/bf4stats.php

    PHP Code:
    <?php

    $lbmember 
    'X-Scipio-X';
    $lbmember 'xxxt0nyxxx';


    $postdata = Array(
                
    'plat' => 'pc',
                
    'name' => "$lbmember",
                
    'output' => 'json'
            
    );
            

            
            
    $c=curl_init('http://api.bf4stats.com/api/playerInfo');
            
    curl_setopt($c,CURLOPT_HEADER,false);
            
    curl_setopt($c,CURLOPT_POST,true);
            
    curl_setopt($c,CURLOPT_HTTPHEADER,array('Expect:'));
            
    curl_setopt($c,CURLOPT_RETURNTRANSFER,true);
            
    curl_setopt($c,CURLOPT_POSTFIELDS,$postdata);
            
    $result json_decode(curl_exec($c));
            
    curl_close($c);
            
            
    //echo($result->player->name);
            
            
    // 200 means a successful call
    if($statusCode == 200
    {
        
    // Decode JSON Data into an array we can easily parse
        
    $data json_decode($resulttrue);
        
        
    // Counter for our players array
        
    $i 0;
        
        
    // Loop through each of our players we set above and see what data we have for them
        
    foreach($result->player->name AS $player)
        {
            
    // Does this player exist in the returned data?
            
    if(isset($data['list'][$player]))
            {
                
    // This checks to see if the player actually has any stats yet on the site
                
    if($data['list'][$player]['status'] == "data")
                {
            
                    
    $stats[$i]['name']         = $data['list'][$player->player->name];
                    
                    
                    
                    
                    
                    
    $i++;
            
        }
        }
        }
        }
        
    ?><br>
        
            <table border="1">
            <thead>
                <tr>
                    <th>#</th>
                    <th>Player</th>
                    <th>Rank</th>
                    <th>Score</th>
                    <th>K/D</th>        
                    <th>Kills</th>
                    <th>Deaths</th>
                    <th>Skill</th>
                    <th>Time</th>
                </tr>
            </thead>
        
            <tbody>
            <?
            
    for($out 0$out count($result->player->name); $out++):
                
    $pos $out 1?>
                
                    <tr>
                        <td class="first"><?=$pos?></td>
                        <td class="soldier"><?=$result->player->name?></td>
                        <td align="center"><?=$result->player->rank->nr?></td>
                        <td><?=$result->player->score?></td>
                        <td><?=mround($result->stats->extra->kdr2)?></td>
                        <td><?=$result->stats->kills?></td>  
                        <td><?=$result->stats->deaths?></td>
                        <td><?=$result->stats->skill?></td>
                        <td><?=sec2hms($result->player->timePlayed)?></td>      
                    </tr>            
            <?
            
    endfor; ?>
                    
            </tbody>
        </table>
    <?


    // Convert seconds to hours
    function sec2hms($num_secs) {
     
    $str '';
     
    $hours intval(intval($num_secs) / 3600);
     
    $str .= $hours.',';
     
    $minutes intval(((intval($num_secs) / 60) % 60));
     if (
    $minutes 10$str .= '0';
     
    $str .= $minutes.' Std';
     

     
    return(
    $str);
     }


    function 
    mround($number$precision=0) {
       
        
    $precision = ($precision == $precision);   
        
    $pow pow(10$precision);
       
        
    $ceil ceil($number $pow)/$pow;
        
    $floor floor($number $pow)/$pow;
       
        
    $pow pow(10$precision+1);
       
        
    $diffCeil     $pow*($ceil-$number);
        
    $diffFloor     $pow*($number-$floor)+($number ? -1);
       
        if(
    $diffCeil >= $diffFloor) return $floor;
        else return 
    $ceil;
    }
    ?>

  2. #2
    Administrator HigH_HawK's Avatar
    Join Date
    2006-03-15
    Location
    UK / GER
    Posts
    1,384

    Re: API PHP example with table output

    Hi Tony,

    it looks like the parameter "name" accepts single user only.

    //EDIT: Just spoke to 1ApRiL and he confirmed my thoughts, at the moment it is not possible to query more than one user at a time.

  3. #3

    Re: API PHP example with table output

    Hello,

    i dont have the same problem but i hope anyone can still help me. If i use this code:
    PHP Code:
    <?php
    include ("../inc/buffer.php");
    include (
    basePath "/inc/config.php");
    include (
    basePath "/inc/bbcode.php");

    $postdata = array('plat' => 'pc''name' => 'DasGelapp''output' => 'json');
    $c curl_init("http://api.bf4stats.com/api/playerInfo");
    curl_setopt($cCURLOPT_HEADERfalse);
    curl_setopt($cCURLOPT_POSTtrue);
    curl_setopt($cCURLOPT_HTTPHEADER, array('Expect:'));
    curl_setopt($cCURLOPT_RETURNTRANSFERtrue);
    curl_setopt($cCURLOPT_POSTFIELDS$postdata);
    $result curl_exec($c);
    echo 
    curl_getinfo($cCURLINFO_HTTP_CODE);
    curl_close($c);
    print_r($result);
    ?>
    i always got the message 500{"error":"unknownPlat"} and i have no idea what i'm doing wrong.
    Where is the mistake?

  4. #4
    Administrator HigH_HawK's Avatar
    Join Date
    2006-03-15
    Location
    UK / GER
    Posts
    1,384

    Re: API PHP example with table output

    Hi,

    it looks like you forgot to decode the json stuff. Try adding this to your code:

    Code:
    json_decode(curl_exec($c));

  5. #5
    ezStats programmer ezzemm's Avatar
    Join Date
    2011-08-18
    Location
    Germany
    Posts
    332
    BFBC2 PC
    ezzemm
    BF2
    siX|ezzemm
    Crysis2 PC
    ezzemm
    MOHW PC
    ezzemm
    Gamer IDs

    Steam ID: ezzemm

    AW: API PHP example with table output

    It seems Postfields doesn't work anymore. I circumvent this by modifying the code:

    PHP Code:
    $get = Array(
        
    'plat' => $platform,
        
    'name' => $name,
        
    'opt' => 'imagePaths,details,names,progress,extra,stats,weapons,weaponCategory,vehicles,vehicleCategory,kititems,awards,dogtags,assignments,urls'
    );

    $c=curl_init('http://api.bf4stats.com/api/playerInfo?plat='.$get['plat'].'&name='.$get['name'].'&opt='.$get['opt'].'&output=json');
    curl_setopt($c,CURLOPT_HEADER,false);
    curl_setopt($c,CURLOPT_HTTPHEADER,array('Expect:'));
    curl_setopt($c,CURLOPT_RETURNTRANSFER,true);
    $result json_decode(curl_exec($c));
    $statuscode curl_getinfo($c,CURLINFO_HTTP_CODE);
    curl_close($c); 
    ezStats.org
    Clanleaderboard for Battlefield 4, Battlefield Hardline, Battlefield 3, Crysis 3, MoH Warfighter, XBOX Live and Playstation Network
    Serverviewer & RCON

  6. #6

    Re: API PHP example with table output

    Thanks ezzemm it works!
    PHP Code:
    $postdata = Array('plat' => 'pc''name' => 'DasGelapp''output' => 'json');

    $c curl_init('http://api.bf4stats.com/api/playerInfo?plat='$postdata['plat'] . '&name=' $postdata['name'] . '&output=' $postdata['output']);
    curl_setopt($cCURLOPT_HEADERfalse);
    curl_setopt($cCURLOPT_HTTPHEADER, array('Expect:'));
    curl_setopt($cCURLOPT_RETURNTRANSFERtrue);
    $result curl_exec($c);
    echo 
    curl_getinfo($cCURLINFO_HTTP_CODE);
    curl_close($c);
    print_r($result); 

  7. #7
    Administrator 1ApRiL's Avatar
    Join Date
    2011-02-12
    Location
    Waiblingen, Germany
    Posts
    1,527
    BFBC2 PC
    1ApRiL
    NFS World
    1APRIL
    BF2
    1ApRiL
    BF3 PC
    1ApRiL

    Re: API PHP example with table output

    Multi part POST data is no longer supported since a module we use is no longer supporting it.

    As of the php curl documentation you can do following:
    Code:
    $postdata = array('plat' => 'pc', 'name' => 'DasGelapp', 'output' => 'json'); 
    $c = curl_init("http://api.bf4stats.com/api/playerInfo"); 
    curl_setopt($c, CURLOPT_HEADER, false); 
    curl_setopt($c, CURLOPT_POST, true); 
    curl_setopt($c, CURLOPT_HTTPHEADER, array('Expect:')); 
    curl_setopt($c, CURLOPT_RETURNTRANSFER, true); 
    curl_setopt($c, CURLOPT_POSTFIELDS, http_build_query($postdata)); 
    $result = curl_exec($c); 
    echo curl_getinfo($c, CURLINFO_HTTP_CODE); 
    curl_close($c); 
    print_r($result);
    I just changed:
    curl_setopt($c, CURLOPT_POSTFIELDS, $postdata);
    to:
    curl_setopt($c, CURLOPT_POSTFIELDS, http_build_query($postdata));

    http://de3.php.net/manual/en/function.curl-setopt.php
    Quote Originally Posted by CURLOPT_POSTFIELDS
    The full data to post in a HTTP "POST" operation. To post a file, prepend a filename with @ and use the full path. The filetype can be explicitly specified by following the filename with the type in the format ';type=mimetype'. This parameter can either be passed as a urlencoded string like 'para1=val1&para2=val2&...' or as an array with the field name as key and field data as value. If value is an array, the Content-Type header will be set to multipart/form-data. As of PHP 5.2.0, value must be an array if files are passed to this option with the @ prefix. As of PHP 5.5.0, the @ prefix is deprecated and files can be sent using CURLFile.
    We get with http_build_query an string and no array anymore which leads to urlencoded and not multipart.
    Admin of bfhstats.com / bf4stats.com / bf3stats.com | Twitter

  8. #8

    Re: API PHP example with table output

    Many thanks for the fast help. This is the final version.
    PHP Code:
    $postData = array();
    $postData['plat'] = 'pc';
    $postData['opt'] = 'clear';
    $postData['output'] = 'json';
    $postData['name'] = 'DasGelapp';

    $c curl_init('http://api.bf4stats.com/api/playerInfo');
    curl_setopt($cCURLOPT_HEADERFALSE);
    curl_setopt($cCURLOPT_POSTTRUE);
    curl_setopt($cCURLOPT_HTTPHEADER, array('Expect:'));
    curl_setopt($cCURLOPT_RETURNTRANSFERTRUE);
    curl_setopt($cCURLOPT_POSTFIELDShttp_build_query($postData));
    $result json_decode(curl_exec($c), TRUE);

    echo 
    curl_getinfo($cCURLINFO_HTTP_CODE);
    curl_close($c);
    $playerInfo $result['player'];
    echo 
    $playerInfo['name'];
    print_r($result); 
    I think it looks good and it works perfectly. Thanks.

  9. #9

    Re: API PHP example with table output

    maybe you can write a note on API page (http://bf4stats.com/api) telling developers that you've changed the way it works...

  10. #10
    ezStats programmer ezzemm's Avatar
    Join Date
    2011-08-18
    Location
    Germany
    Posts
    332
    BFBC2 PC
    ezzemm
    BF2
    siX|ezzemm
    Crysis2 PC
    ezzemm
    MOHW PC
    ezzemm
    Gamer IDs

    Steam ID: ezzemm

    AW: Re: API PHP example with table output

    Quote Originally Posted by 1ApRiL View Post
    Multi part POST data is no longer supported since a module we use is no longer supporting it.

    As of the php curl documentation you can do following:
    Code:
    $postdata = array('plat' => 'pc', 'name' => 'DasGelapp', 'output' => 'json'); 
    $c = curl_init("http://api.bf4stats.com/api/playerInfo"); 
    curl_setopt($c, CURLOPT_HEADER, false); 
    curl_setopt($c, CURLOPT_POST, true); 
    curl_setopt($c, CURLOPT_HTTPHEADER, array('Expect:')); 
    curl_setopt($c, CURLOPT_RETURNTRANSFER, true); 
    curl_setopt($c, CURLOPT_POSTFIELDS, http_build_query($postdata)); 
    $result = curl_exec($c); 
    echo curl_getinfo($c, CURLINFO_HTTP_CODE); 
    curl_close($c); 
    print_r($result);
    I just changed:
    curl_setopt($c, CURLOPT_POSTFIELDS, $postdata);
    to:
    curl_setopt($c, CURLOPT_POSTFIELDS, http_build_query($postdata));

    http://de3.php.net/manual/en/function.curl-setopt.php


    We get with http_build_query an string and no array anymore which leads to urlencoded and not multipart.
    Hi!

    At the moment, I got this error with the new postdata solution:
    [error] => nameInvalid

    Does anybody experience the same?
    ezStats.org
    Clanleaderboard for Battlefield 4, Battlefield Hardline, Battlefield 3, Crysis 3, MoH Warfighter, XBOX Live and Playstation Network
    Serverviewer & RCON

  11. #11
    ezStats programmer ezzemm's Avatar
    Join Date
    2011-08-18
    Location
    Germany
    Posts
    332
    BFBC2 PC
    ezzemm
    BF2
    siX|ezzemm
    Crysis2 PC
    ezzemm
    MOHW PC
    ezzemm
    Gamer IDs

    Steam ID: ezzemm

    AW: API PHP example with table output

    Sorry for pushing this thread. But all I got is [error] => nameInvalid
    ezStats.org
    Clanleaderboard for Battlefield 4, Battlefield Hardline, Battlefield 3, Crysis 3, MoH Warfighter, XBOX Live and Playstation Network
    Serverviewer & RCON

  12. #12
    Administrator HigH_HawK's Avatar
    Join Date
    2006-03-15
    Location
    UK / GER
    Posts
    1,384

    Re: API PHP example with table output

    Hi ezzemm,

    does this happen to any player you put in or is it only with specific ones?

    I tried it with the new method and a few players but could not reproduce this error.

  13. #13
    ezStats programmer ezzemm's Avatar
    Join Date
    2011-08-18
    Location
    Germany
    Posts
    332
    BFBC2 PC
    ezzemm
    BF2
    siX|ezzemm
    Crysis2 PC
    ezzemm
    MOHW PC
    ezzemm
    Gamer IDs

    Steam ID: ezzemm

    AW: API PHP example with table output

    Hi,

    I have copy&pasted the code from 1April. And the error occurs with other names too.

    This code:
    PHP Code:
    $postdata = array('plat' => 'pc''name' => 'DasGelapp''output' => 'json'); 
    $c curl_init("http://api.bf4stats.com/api/playerInfo"); 
    curl_setopt($cCURLOPT_HEADERfalse); 
    curl_setopt($cCURLOPT_CONNECTTIMEOUT5); 
    curl_setopt($cCURLOPT_POSTtrue); 
    curl_setopt($cCURLOPT_HTTPHEADER, array('Expect:')); 
    curl_setopt($cCURLOPT_RETURNTRANSFERtrue); 
    curl_setopt($cCURLOPT_POSTFIELDShttp_build_query($postdata)); 
    $result curl_exec($c); 
    echo 
    curl_getinfo($cCURLINFO_HTTP_CODE); 
    curl_close($c); 
    print_r($result); 
    And this result: http://test.ezstats.org/ezStats3/test.php

    Very weird.
    ezStats.org
    Clanleaderboard for Battlefield 4, Battlefield Hardline, Battlefield 3, Crysis 3, MoH Warfighter, XBOX Live and Playstation Network
    Serverviewer & RCON

  14. #14
    Administrator HigH_HawK's Avatar
    Join Date
    2006-03-15
    Location
    UK / GER
    Posts
    1,384

    Re: API PHP example with table output

    Hmm, this is truelly weird...

    I copy and pasted the same code now and tried it myself but I get a 200 code and the data is showing up. Maybe 1ApRiL can shed some light into this.

  15. #15
    Member
    Join Date
    2011-11-08
    Location
    NRW
    Posts
    112
    BFBC2 PC
    Tony_GER
    BF3 PC
    xXxT0NYxXx

    Re: API PHP example with table output

    My Stats are working fine too. But i cant loop to members :-;

    Demo:
    http://schulte-solingen.de/bf4stats1.php

    PHP Code:

    <?php
    $lbmember 
    = Array();
    $lbmember 'X-Scipio-X';
    $lbmember 'xxxt0nyxxx';



            

            
            
    $get = Array(
        
    'plat' => 'pc',
        
    'name' => $lbmember,
        
    'opt' => 'imagePaths,details,names,progress,extra,stats,weapons,weaponCategory,vehicles,vehicleCategory,kititems,awards,dogtags,assignments,urls'
    );

    $c=curl_init('http://api.bf4stats.com/api/playerInfo?plat='.$get['plat'].'&name='.$get['name'].'&opt='.$get['opt'].'&output=json');
    curl_setopt($c,CURLOPT_HEADER,false);
    curl_setopt($c,CURLOPT_HTTPHEADER,array('Expect:'));
    curl_setopt($c,CURLOPT_RETURNTRANSFER,true);
    $result json_decode(curl_exec($c));
    $statuscode curl_getinfo($c,CURLINFO_HTTP_CODE);
    curl_close($c);  
            
            
    //echo($result->player->name);
            
            
    // 200 means a successful call
    if($statusCode == 200
    {
        
    // Decode JSON Data into an array we can easily parse
        
    $data json_decode($resulttrue);
        
        
    // Counter for our players array
        
    $i 0;
        
        
    // Loop through each of our players we set above and see what data we have for them
        
    foreach($result->player->name AS $player)
        {
            
    // Does this player exist in the returned data?
            
    if(isset($data['list'][$player]))
            {
                
    // This checks to see if the player actually has any stats yet on the site
                
    if($data['list'][$player]['status'] == "data")
                {
            
                    
    $stats[$i]['name']         = $data['list'][$player->player->name];
                    
                    
                    
                    
                    
                    
    $i++;
            
        }
        }
        }
        }
        
    ?><br>
        
            <table border="1">
            <thead>
                <tr>
                    <th>#</th>
                    <th>Player</th>
                    <th>Rank</th>
                    <th>Score</th>
                    <th>K/D</th>        
                    <th>Kills</th>
                    <th>Deaths</th>
                    <th>Skill</th>
                    <th>Time</th>
                </tr>
            </thead>
        
            <tbody>
            <?
            
    for($out 0$out count($result->player->name); $out++):
                
    $pos $out 1?>
                
                    <tr>
                        <td class="first"><?=$pos?></td>
                        <td class="soldier"><?=$result->player->name?></td>
                        <td align="center"><?=$result->player->rank->nr?></td>
                        <td><?=$result->player->score?></td>
                        <td><?=mround($result->stats->extra->kdr2)?></td>
                        <td><?=$result->stats->kills?></td>  
                        <td><?=$result->stats->deaths?></td>
                        <td><?=$result->stats->skill?></td>
                        <td><?=sec2hms($result->player->timePlayed)?></td>      
                    </tr>            
            <?
            
    endfor; ?>
                    
            </tbody>
        </table>
    <?


    // Convert seconds to hours
    function sec2hms($num_secs) {
     
    $str '';
     
    $hours intval(intval($num_secs) / 3600);
     
    $str .= $hours.',';
     
    $minutes intval(((intval($num_secs) / 60) % 60));
     if (
    $minutes 10$str .= '0';
     
    $str .= $minutes.' Std';
     

     
    return(
    $str);
     }


    function 
    mround($number$precision=0) {
       
        
    $precision = ($precision == $precision);   
        
    $pow pow(10$precision);
       
        
    $ceil ceil($number $pow)/$pow;
        
    $floor floor($number $pow)/$pow;
       
        
    $pow pow(10$precision+1);
       
        
    $diffCeil     $pow*($ceil-$number);
        
    $diffFloor     $pow*($number-$floor)+($number ? -1);
       
        if(
    $diffCeil >= $diffFloor) return $floor;
        else return 
    $ceil;
    }
    ?>

  16. #16
    Administrator HigH_HawK's Avatar
    Join Date
    2006-03-15
    Location
    UK / GER
    Posts
    1,384

    Re: API PHP example with table output

    Hi Tony,

    unfortunately this function has still not been implemented yet, so for the time being it would probably help to add a sql query, to add the player to a database, so that you can at least come up with a leaderboard. After that you could just add a few lines of code to regullary update/fetch the new data of a player and save it to the sql table. If I am not mistaken, that is what ezzemm is doing with his leaderboard.

    Hopefully ApRiL can work on the bf4stats.com stuff in the nearer future and reduce the todo list here on the forums.

  17. #17
    New User
    Join Date
    2014-03-22
    Posts
    2

    Re: API PHP example with table output

    Is the order of the items in the array it outputs different depending on the player? I had made a table to display some weapon stats and just realized when I was showing it to someone that his PKP showed all stats as 0, except that is his primary gun he uses so I knew it was wrong.

    After looking, I noticed that when I compare the two json outputs, his(-BH-Wheelz2448) PKP and mine(-BH-XDE4TH) are two different numbers in the array. When I look at the array for my character the PKP is #40 and his is #39.

    Will I need to re-think how I made the stats table to accommodate for these possible variances? I originally made a table and separated it by weapon type(Assault Rifle, LMG, HandGun....) and used my characters output to set the path to look for each weapons stats. Like for example...

    Code:
    <h2>Assault Rifles</h2>
    <table>
    <tr>
    	<th>Weapon</th>
    	<th>Accuracy</th>
            <th>KPM</th>
    	<th>Shots</th>
    	<th>Hits</th>
    	<th>Kills</th>
    	<th>HeadShots</th>
    	<th>HSK%</th>
    </tr>
    <tr>
    <tr>
    	<td>Scar-H</td>
    	<td><?php echo round($result['weapons']['113']['extra']['accuracy'],2); ?>%</td>
    	<td><?php echo round($result['weapons']['113']['extra']['kpm'],2); ?></td>
    	<td><?php echo number_format($result['weapons']['113']['stat']['shots']); ?></td>
    	<td><?php echo number_format($result['weapons']['113']['stat']['hits']); ?></td>
    	<td><?php echo number_format($result['weapons']['113']['stat']['kills']); ?></td>
    	<td><?php echo number_format($result['weapons']['113']['stat']['hs']); ?></td>
    	<td><?php echo round($result['weapons']['113']['extra']['hkp'],2); ?>%</td>
    </tr>
    Last edited by XDE4TH; 2014-03-22 at 22:22.

  18. #18
    Administrator 1ApRiL's Avatar
    Join Date
    2011-02-12
    Location
    Waiblingen, Germany
    Posts
    1,527
    BFBC2 PC
    1ApRiL
    NFS World
    1APRIL
    BF2
    1ApRiL
    BF3 PC
    1ApRiL

    Re: API PHP example with table output

    Never access an item in an array by its index. The index can change any time. Use the id.
    We have the same problem with graphics code. Look into the other threads http://forum.p-stats.com/threads/390...l=1#post102301
    Admin of bfhstats.com / bf4stats.com / bf3stats.com | Twitter

  19. #19
    New User
    Join Date
    2014-03-22
    Posts
    2

    Re: API PHP example with table output

    I've solved that small hiccup I had, thanks for the suggestion April! Now if only the PlayerUpdate function was implemented.
    (In all seriousness though thanks for the useful website and tools!)

  20. #20
    New User
    Join Date
    2018-08-24
    Posts
    4

    Re: API PHP example with table output

    Hello, im back!

    Well after reading this thread, i made an update of the code from the BF3. Trying save the values with specific names which are inside txt. But still don't have values.
    Here is file which is used for the compare names.
    I would appreciate help from more experienced than me.
    Thanks, in advance.

    https://mega.nz/#!9dEkSAqQ!voQ1y5vSp...4hS6AnPYkW0FeE

    Code:
    				$username = $this->user['username'];
    
    				$statNamesbf4 = file("statnamesbf4.dat");
    				$statNamesbf4 = explode(";",$statNamesbf4[0]);
    
    
    				$postdata4 = Array(
    					'player' => 'player',
    					'game' => 'bf4',
    					'plat' => 'pc',
    					'name' => $username,
    					'opt' => 'names,progress,extra,stats,weapons,weaponCategory,vehicles,vehicleCategory,kititems,awards,dogtags,assignments',
    					'output' => 'json'	
    				);
    
    								
    				$c4 = curl_init('http://api.bf4stats.com/api/playerInfo');
    				curl_setopt($c4, CURLOPT_HEADER, false); 
    				curl_setopt($c4, CURLOPT_POST, true);
    				curl_setopt($c4, CURLOPT_HTTPHEADER, array('Expect:')); 
    				curl_setopt($c4, CURLOPT_RETURNTRANSFER, true); 
    				curl_setopt($c4, CURLOPT_POSTFIELDS, http_build_query($postdata4));
    				$resultbf4 = curl_exec($c4); 
    				$statuscode4 = curl_getinfo($c4, CURLINFO_HTTP_CODE); 
    				curl_close($c4); 
    
    				if($statuscode4 == 200)  
    						{
    							$data4 = json_decode($resultbf4,true);
    				                	$statData4 = $data4['player'];						
    					
    								for($i = 0 ; $i < count($statNamesbf4) ; $i++)
    									{
    										$statCopySQL4 .= $statNamesbf4[$i]."=";
    										$statCopySQL4 .= $data4['player'][$statNamesbf4[$i]]."\n";
    									}	
    								$allbf4stats = $statCopySQL4;	
    								$BF4stats = fopen("BF4stats.txt", "w") or die("Unable to open file!");
    								fwrite($BF4stats, $allbf4stats);
    								fclose($BF4stats);
    								
    						}
    						else
    							{
    								throw new \Exception("BF4 Stats API error status: ".$statuscode, 1);
    							}
    Edit: This settup save two things only :
    score: "real and corect number"
    rank: "Array"
    Last edited by bruca; 2019-09-23 at 19:06.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
P-STATS NETWORK FORUM LOGIN CREATE ACCOUNT