21,887
社区成员
发帖
与我相关
我的任务
分享
set_time_limit(0);
error_reporting(1024);
ob_start();
header("Content-Type:text/html;charset=utf-8");
//header('Cache-Control:no-cache,must-revalidate');
header('Pragma:no-cache');
ini_set('date.timezone','Asia/Shanghai');
$url = 'http://i.sporttery.cn/odds_calculator/get_odds?i_format=json&poolcode[]=hhad&poolcode[]=had';
$content = getCurlData($url);
var_dump($content);
function getCurlData($url){
$cookie = tempnam("/tmp", "cookie");
//先获取 cookie
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
curl_exec($ch);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,TRUE);
$cdata = curl_exec($ch);
$info = curl_getinfo($ch);
var_dump($info);
/*
if($info['http_code']==302){
getCurlData($url);
}
*/
curl_close($ch);
return $cdata;
}
ob_end_flush();
exit;