View Full Version : PHP: Help.
NexPB
02-10-2012, 05:49 PM
How can I get the vars from SRL-stats? With php ofcourse :D
Kyle Undefined
02-10-2012, 05:52 PM
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.
NexPB
02-10-2012, 06:16 PM
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.
I don't know how to parse JSON never used it before :s
Kyle Undefined
02-10-2012, 06:19 PM
PHP has a built in object that parses it for you :)
NexPB
02-10-2012, 06:32 PM
PHP has a built in object that parses it for you :)
I have this but how can I get now each var individual?
$jsonurl = "http://stats.villavu.com/api/script/667";
$json1 = file_get_contents($jsonurl);
$data = json_decode($json1, TRUE);
NexPB
02-11-2012, 11:52 PM
Bump this is what I have so far
$jsonurl = "http://stats.villavu.com/api/script/667";
$json = file_get_contents($jsonurl);
$data = json_decode($json, TRUE);
$dump = var_dump($data);
$result = $data["vars"][0][0];
Kyle Undefined
02-12-2012, 01:49 AM
This is how I'm doing it on my page to display the stat vars:
$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>";
}
var[0] is the ID of the stat var, and var[1] is the name.
NexPB
02-12-2012, 01:03 PM
This is how I'm doing it on my page to display the stat vars:
$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>";
}
var[0] is the ID of the stat var, and var[1] is the name.
Thanks.
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.