php获取违章数据
2015-05-21 09:41
211 查看
就这些,自己用的
<?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.']}'; } ?>
相关文章推荐
- PHP获取POST数据的几种方法汇总
- PHP获取POST数据的几种方法汇总
- php的curl获取https加密协议请求返回json数据进行信息获取
- jquery $.ajax+php使用jsonp处理数据时,前端success :function无法获取服务器返回数据
- 模拟页面获取的php数据(三)
- php获取数据库中数据生成json,中文乱码问题的解决方案
- PHP获取HTML文件名表单数据等
- php获取实时汇率数据
- 使用的php获取数据库数据导出到页面
- PHP模拟登录并获取数据
- php如何获取json数据?
- 解决php使用异步调用获取数据时出现(错误c00ce56e导致此项操作无法完成)
- php获取数组中重复数据的两种方法
- php 获取并解析哈工大ltp-cloud返回的json数据
- php依据地理坐标获取国家、省份、城市,及周边数据类
- Ajax获取PHP服务器上的 Json数据以及POST的综合实例
- 探讨PHP获取Oracle数据乱码的相关问题解决办法
- php从数据库中获取数据用ajax传送到前台
- PHP通过计算经纬度获取附近的数据信息
- ajax无刷新获取php后台数据