- file_get_contents: documentation ( source)
- json_decode: documentation ( source)
- readfile: documentation ( source)
- header: documentation ( source)
- filesize: documentation ( source)
- file_exists: documentation ( source)
<?php
echo "Downloading... ";
$json = file_get_contents('http://m.vip.com/ajaxapi-classify.html?query=27967&limit=10000');
echo "[O.K.]\n";
$obj = json_decode($json);
echo (float)$obj->data[0]->discount;
if (file_exists($obj)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename="test.txt"');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
header('Content-Length: ' . filesize($obj));
readfile($obj);
exit;
}
?>