php获取违章数据

就这些,自己用的

<?php 
header("Content-type: text/html; charset=utf-8");
date_default_timezone_set('PRC');
set_time_limit(0);

if (!empty($GLOBALS['HTTP_RAW_POST_DATA']))
{
	$json =  isset($GLOBALS['HTTP_RAW_POST_DATA']) ? $GLOBALS['HTTP_RAW_POST_DATA'] : file_get_contents("php://input");
}
//$json='{"type":"weizhang","name":"苏N12345","code":"1234"}';
$json=iconv('UTF-8', 'UTF-8//IGNORE', $json);
$json=urldecode($json);
$array2=json_decode($json, true);
$str_json_data='';
if($array2['type']=="weizhang")
{
	$str_json='';
	$name=substr($array2['name'],4);
	$url = 'http://www.sqjg.net/Jgcx/DEFAULT.ASPX';
	$data = array ('__msg' => '14,3,69;Jgcx.VehDetailxhr4,7,2,4,10,28;args'.$array2['name'].'02'.$array2['code'].'$'.$name.$array2['code'].'$<'.substr($name,0,1).'><'.substr($name,1,1).'><'.substr($name,2,1).'><'.substr($name,3,1).'><'.substr($name,4,1).'><'.substr($array2['code'],0,1).'><'.substr($array2['code'],1,1).'><'.substr($array2['code'],2,1).'><'.substr($array2['code'],3,1).'>'); 
	$data = http_build_query($data); 
	$opts = array ( 
		'http' => array ( 
		   'method' => 'POST', 
		   'header'=> "Content-type: application/x-www-form-urlencoded\r\n" . 
							 "Content-Length: " . strlen($data) . "\r\n". 
						 "cookie:ASP.NET_SessionId=fohp5j45rldj2v55yz0mx445;cookie2=c2\r\n", 
		   'content' => $data
		) 
	); 
	$ctx = stream_context_create($opts); 
	$html = @file_get_contents($url,'',$ctx);

	$html=substr($html,10);
	$html=str_replace("'",'"',$html);
	$array=json_decode($html, true);
	$str_json="{\"yxqz\":\"".$array['YXQZ']."\",\"zt\":\"".$array['ZT']."\",\"RegisteredNo\":\"".$array['RegisteredNo']."\",\"gxrq\":\"".$array['GXRQ']."\",\"name\":\"".$array2['name']."\",\"code\":\"".$array2['code']."\",\"data\": [";

	$url = 'http://www.sqjg.net/Jgcx/DEFAULT.ASPX'; 
	$data = array ('__msg' => '11,3,19;Jgcx.getVioxhr4,7,2;args'.$array2['name'].'02'); 
	$data = http_build_query($data); 
	$opts = array ( 
	'http' => array ( 
	   'method' => 'POST', 
	   'header'=> "Content-type: application/x-www-form-urlencoded\r\n" . 
						 "Content-Length: " . strlen($data) . "\r\n". 
					 "cookie:ASP.NET_SessionId=fohp5j45rldj2v55yz0mx445;cookie2=c2\r\n", 
	   'content' => $data
	) 
	); 
	$ctx = stream_context_create($opts); 
	$html = @file_get_contents($url,'',$ctx);

	$html=substr($html,11);
	$html=str_replace("]]",']',$html);
	$html=str_replace("'",'"',$html);
	$html='{"aa":"bb","data":['.$html.']}';
	$html=iconv('UTF-8', 'UTF-8//IGNORE', $html);
	$array=json_decode($html, true);

	$result=$array['data'];
	for($i=0;$i<count($result);$i++){
		$str_json_data.=',{"reason":"'.$result[$i][0].'",
							"time":"'.$result[$i][1].'",
							"place":"'.$result[$i][2].'",
							"code":"'.$result[$i][3].'",
							"find":"'.$result[$i][4].'",
							"findtime":"'.$result[$i][5].'",
							"findtype":"'.$result[$i][6].'",
							"code2":"'.$result[$i][7].'",
							"points":"'.$result[$i][8].'",
							"money":"'.$result[$i][9].'"
							}';
	}
	$str_json_data=mb_substr($str_json_data,1);
	echo $str_json.$str_json_data.']}';
}
?>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值