NexPB
2012-02-10 12:49:48
How can I get the vars from SRL-stats? With php ofcourse :D
2012-02-10 12:49:48
2012-02-10 12:52:49
2012-02-10 13:16:13
From: Kyle Undefined
SRL stats has an API that creates a JSON object when called, you just have to call that API and parse it with the PHP.
2012-02-10 13:19:02
2012-02-10 13:32:35
From: Kyle Undefined
PHP has a built in object that parses it for you :)
2012-02-11 18:52:25
2012-02-11 20:49:04
2012-02-12 08:03:00
From: Kyle Undefined
This is how I'm doing it on my page to display the stat vars:
[PHP]$data = @file_get_contents("http://stats.villavu.com/api/script/".$id);
if(!$data){
die("Failure retrieving data.");
}
$data = @json_decode($data);
if(!$data){
die("Invalid data format.");
}
foreach($data as $key => $value){
$$key = $value;
}
foreach($vars as $var){
$options .= "<td style='width:21%;'><input type=\"checkbox\" value=\"{$var[1]}\" id=\"{$var[0]}\" />{$var[1]}</td>";
}[/PHP]
var[0] is the ID of the stat var, and var[1] is the name.