Veriyi önce json.txt dosyasına yazar ve veriyi ordan çeker. Sayfa her yenilendiğinde veride yenilenir.
<?php
$url = 'http://www.mackolik.com/AjaxHandlers/IddaaHandler.aspx?command=morebets&mac=974947&type=ByLeage&duel=duelloArray';
$urlHandle = _fwrite(http_request($url)); // Veriyi txt'e yazdir
$datam = file_get_contents('json.txt');
$data = json_decode(fix_json_format($datam));
print_R($data);
function _fwrite($data)
{
$file = fopen('json.txt','w');
fwrite($file,fix_json_format($data));
fclose($file);
}
function http_request($url){
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 0);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
function fix_json_format($json){
$a = preg_replace('/\,\s?([a-zA-Z0-9]+)\:/i',',"${1}":',$json);
$a = preg_replace('/\{([a-zA-Z0-9]+)\:/i','{"${1}":',$a);
$a = preg_replace('/[\n\r]+/','',$a);
$a = str_replace('\'', '"', $a);
$a = str_replace(' ', '', $a);
$res = fix_blank_comas($a);
return $res;
}
function fix_blank_comas($str){
$go=87;
for($i=0;$i<$go;$i++){
$str = str_replace(',,',',"",',$str);
}
return $str;
}