这一章将介绍最后几个查询功能。过年前这段时间打算好好熟悉一下手机商城这一块,将我的小魔方童装重新调整一下它的手机显示界面风格。
效果图
4.6:双色球开奖查看
4.7:股票查看
4.9:身份证查询
4.8:快递查询
查询代码如下
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
//双色球彩票
private function get_lottery(){
$xml =
simplexml_load_file( $url );
$content = "" ;
foreach ( $xml ->row as $i => $v )
{
$arr =
current(( array ) $v ->attributes());
$content .= "20" . $arr [ "expect" ]. "期,开奖号:" . $arr [ "opencode" ]. "\n" ;
}
return array ( $content , "text" );
}
//股票
private function get_stock( $find_name ){
$param = array ( "list" => $find_name );
$datas =utf8( $datas );
if ( empty ( $datas )){
return array ( "输入sz(深圳),sh(上海)+股票码" , "text" );
}
$datas = str_replace ( "var
hq_str_$find_name=" , "" , $datas );
$arr =preg_split( "/,/" , $datas );
$content = "股票名称:" . $arr [0]. "\n" ;
$content .= "今日开盘价:" . $arr [1]. "\n" ;
$content .= "昨日收盘价:" . $arr [2]. "\n" ;
$content .= "当前价格:" . $arr [3]. "\n" ;
$content .= "今日最高价:" . $arr [4]. "\n" ;
$content .= "今日最低价:" . $arr [5]. "\n" ;
$content .= "竞买价:" . $arr [6]. "\n" ;
$content .= "竞卖价:" . $arr [7]. "\n" ;
$content .= "成交的股票数:" . $arr [8]. "\n" ;
$content .= "成交金额(元):" . $arr [9]. "\n" ;
$content .= "买一:申请" . $arr [10]. "股,报价:" . $arr [11]. "\n" ;
$content .= "买二:申请:" . $arr [12]. "股,报价:" . $arr [13]. "\n" ;
$content .= "买三:申请:" . $arr [14]. "股,报价:" . $arr [15]. "\n" ;
$content .= "卖一:申报:" . $arr [20]. "股,报价:" . $arr [21]. "\n" ;
$content .= "卖二:申报:" . $arr [22]. "股,报价:" . $arr [23]. "\n" ;
$content .= "卖三:申报:" . $arr [24]. "股,报价:" . $arr [25]. "\n" ;
$content .= "日期:" . $arr [30]. "\n" ;
$content .= "时间:" . $arr [31]. "\n" ;
return array ( $content , "text" );
}
//快递
private function get_expressage( $find_name ){
//先查找是哪家快递
$post_datas =json_decode( $rdata );
$content = "" ;
foreach ( $post_datas as $row ){ //如果找到多个快递,一个一个试吧
$kuaidiCode = $row ->comCode;
$get_http = "http://www.kuaidi100.com/query?type=$kuaidiCode&postid;=$find_name&id=1&valicode;=&temp=0.7709468309767544" ;
$get_datas =http( $get_http );
$g_datas =json_decode( $get_datas );
if ( $g_datas ->status== "200" ){
$datas = $g_datas ->data;
foreach ( $datas as $row ){
$content .= "\n" . $row ->time. "\n" . $row ->context. "
\n" ;
}
break ;
}
}
if ( empty ( $content )){
$content = "快递公司参数异常:单号不存在或者已经过期." ;
}
return array ( $content , "text" );
}
//身份证
private function get_cardNo( $find_name ){
$param = array (
"app" => "idcard.get" ,
"idcard" => $find_name ,
"appkey" => "10003" ,
"sign" => "b59bc3ef6191eb9f747dd4e83c99f2a4" ,
"format" => "json"
);
$rdata =http( $url , $param );
$data =json_decode( $rdata );
if ( $data ->success==1){
$obj = $data ->result;
$content = "身份证号:" . $obj ->idcard. "
\n" ;
$content .= "所在
地 :" . $obj ->att. "
\n" ;
$content .= "出生年月:" . $obj ->born. "
\n" ;
$content .= "性
别 :" . $obj ->sex. "
\n" ;
} else {
$content = "未找到当前身份证信息,请检查是否输入正确." ;
}
return array ( $content , "text" );
}
|
OK,打完收工