CET准考证号查询

  • 2017-08-23
  • 0
  • 0
header('Content-type: application/json;charset=utf-8');
date_default_timezone_set('PRC');
if(!isset($_REQUEST['NM'])||empty($_REQUEST['NM'])||!isset($_REQUEST['ID'])||empty($_REQUEST['ID'])||!isset($_REQUEST['KD'])||empty($_REQUEST['KD'])){
	$data=array(
	'status'=>'403',
	'ks_nm'=>'',
	'ks_id'=>'',
	'ks_bh'=>'',
	'msg'=>'数据缺失'
	);
	echo json_encode($data,JSON_UNESCAPED_UNICODE);
	exit;
	}
function XCURL($url,$cookie,$post,$referer){
        $ip = mt_rand(1,255).".".mt_rand(1,255).".".mt_rand(1,255).".".mt_rand(1,255)."";
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
        curl_setopt($ch, CURLOPT_HEADER, 0);
        curl_setopt($ch,CURLOPT_HTTPHEADER,array("CLIENT-IP:".$ip."", "Content-Type:"."application/x-www-form-urlencoded; charset=UTF-8"."","X_FORWARD_FOR:".$ip."")); 
        curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36");
        curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); 
        curl_setopt($ch, CURLOPT_TIMEOUT,30);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
		curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie); 
        curl_setopt($ch, CURLOPT_REFERER, $referer);   
        curl_setopt($ch, CURLOPT_POSTFIELDS,$post);  
		curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept-Encoding:gzip'));
        curl_setopt($ch, CURLOPT_ENCODING, "gzip");
        $result=curl_exec($ch);
        curl_close($ch);  
        return $result;
    }
	$url='http://app.cet.edu.cn:7066/baas/app/setuser.do?method=UserVerify';
	$cookie = dirname(__FILE__)."/pic.cookie";
	$referer='http://app.cet.edu.cn:7066/baas/app/setuser.do?method=UserVerify';
	$data=array(
	'ks_xm'=>$_REQUEST['NM'],
	'ks_sfz'=>$_REQUEST['ID'],
	'jb'=>$_REQUEST['KD']
	);
	$post=array(
        'action'=>'',
        'params'=>json_encode($data)
    );
	$html=XCURL($url,$cookie,http_build_query($post),$referer);
	$sid=json_decode($html,true);
	if(empty($sid['msg'])&&!empty($sid['ks_bh'])){
	$data=array(
	'status'=>'200',
	'ks_nm'=>$_REQUEST['NM'],
	'ks_id'=>$_REQUEST['ID'],
	'ks_bh'=>$sid['ks_bh'],
	'msg'=>''
	);
	$bh=$sid['ks_bh'];
	}else{
	$data=array(
	'status'=>'400',
	'ks_nm'=>'',
	'ks_id'=>'',
	'ks_bh'=>'',
	'msg'=>'本次考试未通过|提交的数据有误|数据库中无匹配信息'
	);
	$bh='Null';
	}
	echo json_encode($data,JSON_UNESCAPED_UNICODE);

评论

还没有任何评论,你来说两句吧

CC共享许可协议:BY-NC-SA 4.0 - 友情链接 - Theme by Qzhai