<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
function run(){
$apiKey = 'demo';
$clanMembers = json_decode(getData('http://api.worldoftanks.com/wgn/clans/info/?application_id='.$apiKey.'&fields=members.account_name%2Cmembers.account_id&clan_id=1000021200'),true);
$data = array();
$players = array();
foreach ($clanMembers['data']['1000021200']['members'] as $key) {
$urls[] = 'http://api.worldoftanks.com/wot/globalmap/eventaccountinfo/?application_id='.$apiKey.'&fields=events.battles%2Cevents.battles_to_award%2Cevents.fame_points%2Cevents.rank&event_id=black_gold_first_step&front_id=1511_us_c4event1_front_1&account_id='.$key['account_id'];
$players[] = array($key['account_name'],$key['account_id']);
}
$urls = array_chunk($urls, 20,true);
for($i = 0;$i<5;$i++){
$data = array_merge($data,multiRequest($urls[$i]));
}
$data2 = array();
foreach ($data as $key => $value) {
//echo $key;
$data2[$players[$key][1]] = json_decode($value,true)['data'][$players[$key][1]]['events']['black_gold_first_step'];
$data2[$players[$key][1]][0]['account_name'] = $players[$key][0];
$data2[$players[$key][1]][0]['account_id'] = $players[$key][1];
}
print_r($data2);
return $data2;
}
function getData($url){
$rCURL = curl_init();
curl_setopt($rCURL, CURLOPT_URL, $url);
curl_setopt($rCURL, CURLOPT_HEADER, 0);
curl_setopt($rCURL, CURLOPT_RETURNTRANSFER, 1);
$aData = curl_exec($rCURL);
curl_close($rCURL);
return $aData;
}
function multiRequest($data, $options = array()) {
// array of curl handles
$curly = array();
// data to be returned
$result = array();
// multi handle
$mh = curl_multi_init();
// loop through $data and create curl handles
// then add them to the multi-handle
foreach ($data as $id => $d) {
$curly[$id] = curl_init();
$url = (is_array($d) && !empty($d['url'])) ? $d['url'] : $d;
curl_setopt($curly[$id], CURLOPT_URL, $url);
curl_setopt($curly[$id], CURLOPT_HEADER, 0);
curl_setopt($curly[$id], CURLOPT_RETURNTRANSFER, 1);
// post?
if (is_array($d)) {
if (!empty($d['post'])) {
curl_setopt($curly[$id], CURLOPT_POST, 1);
curl_setopt($curly[$id], CURLOPT_POSTFIELDS, $d['post']);
}
}
// extra options?
if (!empty($options)) {
curl_setopt_array($curly[$id], $options);
}
curl_multi_add_handle($mh, $curly[$id]);
}
// execute the handles
$running = null;
do {
curl_multi_exec($mh, $running);
} while($running > 0);
// get content and remove handles
foreach($curly as $id => $c) {
$result[$id] = curl_multi_getcontent($c);
curl_multi_remove_handle($mh, $c);
}
// all done
curl_multi_close($mh);
return $result;
}
?>
<html>
<head>
<title>Fame Points -MO-</title>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.10/css/jquery.dataTables.min.css">
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/s/dt/dt-1.10.10/datatables.min.css"/>
<script type="text/javascript" src="https://cdn.datatables.net/s/dt/dt-1.10.10/datatables.min.js"></script>
</head>
<body>
<table id="example" class="display" cellspacing="0">
<thead>
<tr>
<th>Player</th>
<th>Battles</th>
<th>Rank</th>
<th>Fame Points</th>
<th>Battles Needed</th>
</tr>
</thead>
<tbody>
<?php
$data = run();
//print_r($data);
foreach ($data as $value) {
if($value[0]['battles']>0){
echo "<tr>
<td>".$value[0]['account_name']."</td>
<td>".$value[0]['battles']."</td>
<td>".$value[0]['rank']."</td>
<td>".$value[0]['fame_points']."</td>
<td>".$value[0]['battles_to_award']."</td>
</tr>";
}
}
?>
</tbody>
</table>
<script type="text/javascript">
$(document).ready(function() {
$('#example').DataTable();
} );
</script>
</body>
</html>
- Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
- <html>
<head>
<title>Fame Points -MO-</title>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.10/css/jquery.dataTables.min.css">
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/s/dt/dt-1.10.10/datatables.min.css"/>
<script type="text/javascript" src="https://cdn.datatables.net/s/dt/dt-1.10.10/datatables.min.js"></script>
</head>
<body>
<table id="example" class="display" cellspacing="0">
<thead>
<tr>
<th>Player</th>
<th>Battles</th>
<th>Rank</th>
<th>Fame Points</th>
<th>Battles Needed</th>
</tr>
</thead>
<tbody>
Fatal error: Uncaught Error: Call to undefined function curl_init() in /in/djbtm:37
Stack trace:
#0 /in/djbtm(9): getData('http://api.worl...')
#1 /in/djbtm(144): run()
#2 {main}
thrown in /in/djbtm on line 37
Process exited with code 255. - Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
- <html>
<head>
<title>Fame Points -MO-</title>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.10/css/jquery.dataTables.min.css">
<script type="text/javascript" src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/s/dt/dt-1.10.10/datatables.min.css"/>
<script type="text/javascript" src="https://cdn.datatables.net/s/dt/dt-1.10.10/datatables.min.js"></script>
</head>
<body>
<table id="example" class="display" cellspacing="0">
<thead>
<tr>
<th>Player</th>
<th>Battles</th>
<th>Rank</th>
<th>Fame Points</th>
<th>Battles Needed</th>
</tr>
</thead>
<tbody>
Fatal error: Call to undefined function curl_init() in /in/djbtm on line 37
Process exited with code 255.
preferences:
235.78 ms | 403 KiB | 327 Q