array('header'=>"Referer: $refer")); //请求头部数组 $context=stream_context_create($opt); //创建一个发送上下文头部信息文本 $jsonUrl ="http://city.qq.com/json.php?mod=search&act=page&callback=showSrchResult&jsontype=str&perpage=10&cd=610900&nl=3&xb=0&type=city&pg=1"; $jsonStr = getJson($jsonUrl,$refer,$context); //调用JSON代理函数 echo $jsonStr; //输出JSON文本 //获取QQ达人JSON数据 function getJson($url,$referer,$context) { $opt=array('http'=>array('header'=>"Referer: $referer")); $context=stream_context_create( $opt); $getJsonStr = file_get_contents( $url,false, $context); $getJsonStr = substr($getJsonStr,0,-2); $getJsonStr = substr($getJsonStr,15); return $getJsonStr; } ?>