日期:2014-05-17 浏览次数:20580 次
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<script type='text/javascript'>
function jsonp145(data){
alert(data.status.code);//200
}
</script>
<script src='http://list.taobao.com/itemlist/default.htm?_input_charset=utf-8&json=on&cat=0&style=grid&pcat=food2011&q=ps&rr=1&spm=a2106.m5221.1000187.1&commend=all&pSize=95&_ksTS=1382516137021_144&callback=jsonp145'></script>
</body>
</html>
$url = 'http://list.taobao.com/itemlist/default.htm?_input_charset=utf-8&json=on&cat=0&style=grid&pcat=food2011&q=ps&rr=1&spm=a2106.m5221.1000187.1&commend=all&pSize=95&_ksTS=1382516137021_144&callback=jsonp145';Array
$s = file_get_contents($url);
preg_match('/{.+}/s', $s, $r); //他返回的是js函数,所以需要脱括号
$o = json_decode(iconv('gbk', 'utf-8', $r[0]), true);//他的数据是gbk的,但json_decode只能处理utf-8的函数
print_r($o);