Api highscore
Nu stuit ik op een probleem hij laat keurig alle arrays zien zoals het hoord.
Alleen nu wil ik dus eigenlijk alle arrays in 3 rijen hebben onder elkaar.
Met een plaatje voor elke array.
Kan iemand mij hier mee verder helpen ?
In onderstaant plaatje heb ik het een klein beetje duidelijker gemaakt.
Zo izet het er nu uit
http://infinitesoul.r4u.nl/hiscores_old.php?user=Slap_a_fatty
Bedankt
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
$user = urldecode($_GET['user']);
if(isset($_GET['callback'])) $callback = $_GET['callback'];
function getStats($name) {
$hiscores = array("Overall",
"stats" => array(
"Attack", "Defence", "Strength",
"Hitpoints", "Ranged", "Prayer",
"Magic", "Cooking", "Woodcutting",
"Fletching", "Fishing", "Firemaking",
"Crafting", "Smithing", "Mining",
"Herblore", "Agility", "Thieving",
"Slayer", "Farming", "Runecrafting",
"Hunter", "Construction", "Summoning",
"Dungeoneering"
),
"minigames" => array(
"Duel Tournaments", "Bounty Hunters",
"Bounty Hunter Rogues", "Fist of Guthix",
"Mobilising Armies", "B.A Attackers",
"B.A Defenders", "B.A Healers",
"Castle Wars Games", "Conquest"
)
);
$name = strtolower($name);
$connection = fopen('http://services.runescape.com/m=hiscore_oldschool/index_lite.ws?player='.$name, 'rb');
$data = stream_get_contents($connection);
fclose($connection);
$data = explode("\n", $data);
$overall = explode(',', $data[0]);
$stats['overall'] = array("Rank" => $overall[0], "Level" => $overall[1], "XP" => $overall[2]);
for($i = 0; $i < 25; $i++) {
$cItem = $hiscores['stats'][$i];
$num = explode(',', $data[$i+1]);
$stats['skills'][$cItem] = array("Rank" => $num[0], "Level" => $num[1], "XP" => $num[2]);
}
for($i = 0; $i < 9; $i++){
$cItem = $hiscores['minigames'][$i];
$num = explode(',', $data[$i+27]);
$stats['minigames'][$cItem] = array("Rank" => $num[0], "Score" => $num[1]);
}
$stats = json_encode($stats);
$stats = str_replace('-1', '', $stats);
if($_GET['lowercase'] === 'yes'){
$stats = strtolower($stats);
}
return $stats;
}
if(isset($_GET['user'])) {
$cStats = getStats($user);
if(isset($callback)) {
echo $callback.'('.$cStats.')';
}
else
{
echo $cStats;
}
}
else
{
echo 'Usage:<br><ul>';
echo '<li>user=username</li>';
echo '<li>Optional: callback=funcName</li>';
echo '<li>Optional: lowercase=yes (all json will be lower case)</li></ul><br>';
echo 'Callback function is used for cross-domain AJAX requests';
}
?>
$user = urldecode($_GET['user']);
if(isset($_GET['callback'])) $callback = $_GET['callback'];
function getStats($name) {
$hiscores = array("Overall",
"stats" => array(
"Attack", "Defence", "Strength",
"Hitpoints", "Ranged", "Prayer",
"Magic", "Cooking", "Woodcutting",
"Fletching", "Fishing", "Firemaking",
"Crafting", "Smithing", "Mining",
"Herblore", "Agility", "Thieving",
"Slayer", "Farming", "Runecrafting",
"Hunter", "Construction", "Summoning",
"Dungeoneering"
),
"minigames" => array(
"Duel Tournaments", "Bounty Hunters",
"Bounty Hunter Rogues", "Fist of Guthix",
"Mobilising Armies", "B.A Attackers",
"B.A Defenders", "B.A Healers",
"Castle Wars Games", "Conquest"
)
);
$name = strtolower($name);
$connection = fopen('http://services.runescape.com/m=hiscore_oldschool/index_lite.ws?player='.$name, 'rb');
$data = stream_get_contents($connection);
fclose($connection);
$data = explode("\n", $data);
$overall = explode(',', $data[0]);
$stats['overall'] = array("Rank" => $overall[0], "Level" => $overall[1], "XP" => $overall[2]);
for($i = 0; $i < 25; $i++) {
$cItem = $hiscores['stats'][$i];
$num = explode(',', $data[$i+1]);
$stats['skills'][$cItem] = array("Rank" => $num[0], "Level" => $num[1], "XP" => $num[2]);
}
for($i = 0; $i < 9; $i++){
$cItem = $hiscores['minigames'][$i];
$num = explode(',', $data[$i+27]);
$stats['minigames'][$cItem] = array("Rank" => $num[0], "Score" => $num[1]);
}
$stats = json_encode($stats);
$stats = str_replace('-1', '', $stats);
if($_GET['lowercase'] === 'yes'){
$stats = strtolower($stats);
}
return $stats;
}
if(isset($_GET['user'])) {
$cStats = getStats($user);
if(isset($callback)) {
echo $callback.'('.$cStats.')';
}
else
{
echo $cStats;
}
}
else
{
echo 'Usage:<br><ul>';
echo '<li>user=username</li>';
echo '<li>Optional: callback=funcName</li>';
echo '<li>Optional: lowercase=yes (all json will be lower case)</li></ul><br>';
echo 'Callback function is used for cross-domain AJAX requests';
}
?>
Gewijzigd op 11/02/2015 20:18:50 door Andytjuh Bruggeman
Er zijn nog geen reacties op dit bericht.