2014年6月全国大学英语四、六级考试考试成绩于2014年8月20日上午9时发布
我们提供微信查询方法
1、关注微信公众账号

二、回复“四六级”

三、输入姓名和准考证号

四、返回查询结果

代码实现
responseMsg();
12 }else{
13 $wechatObj->valid();
14 }
15
16 class wechatCallbackapiTest
17 {
18 public function valid()
19 {
20 $echoStr = $_GET["echostr"];
21 $signature = $_GET["signature"];
22 $timestamp = $_GET["timestamp"];
23 $nonce = $_GET["nonce"];
24 $token = TOKEN;
25 $tmpArr = array($token, $timestamp, $nonce);
26 sort($tmpArr);
27 $tmpStr = implode($tmpArr);
28 $tmpStr = sha1($tmpStr);
29 if($tmpStr == $signature){
30 echo $echoStr;
31 exit;
32 }
33 }
34
35 public function responseMsg()
36 {
37 $postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
38 if (!empty($postStr)){
39 $this->logger("R ".$postStr);
40 $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
41 $RX_TYPE = trim($postObj->MsgType);
42
43 switch ($RX_TYPE)
44 {
45 case "event":
46 $result = $this->receiveEvent($postObj);
47 break;
48 case "text":
49 $result = $this->receiveText($postObj);
50 break;
51 }
52 $this->logger("T ".$result);
53 echo $result;
54 }else {
55 echo "";
56 exit;
57 }
58 }
59
60 private function receiveEvent($object)
61 {
62 $content = "";
63 switch ($object->Event)
64 {
65 case "subscribe":
66 $content = array();
67 $content[] = array("Title" =>"2014年6月全国大学英语四六级考试成绩查询","Description" =>"", "PicUrl" =>"http://365jia.cn/uploads/13/0301/5130c2ff93618.jpg", "Url" =>"http://apix.sinaapp.com/cet/index.php?openid=".$object->FromUserName);
68 break;
69 }
70 if(is_array($content)){
71 $result = $this->transmitNews($object, $content);
72 }else{
73 $result = $this->transmitText($object, $content);
74 }
75 return $result;
76 }
77
78 private function receiveText($object)
79 {
80 $keyword = trim($object->Content);
81 if (strstr($keyword, "四六级") || strstr($keyword, "英语")){
82 $content = array();
83 $content[] = array("Title" =>"2014年6月全国大学英语四六级考试成绩查询","Description" =>"", "PicUrl" =>"http://365jia.cn/uploads/13/0301/5130c2ff93618.jpg", "Url" =>"http://apix.sinaapp.com/cet/index.php?openid=".$object->FromUserName);
84 }else{
85 $content = date("Y-m-d H:i:s",time())."n技术支持 方倍工作室";
86 }
87 if(is_array($content)){
88 $result = $this->transmitNews($object, $content);
89 }else{
90 $result = $this->transmitText($object, $content);
91 }
92 return $result;
93 }
94
95 private function transmitText($object, $content)
96 {
97 $textTpl = "
98
99
100 %s
101
102
103 ";
104 $result = sprintf($textTpl, $object->FromUserName, $object->ToUserName, time(), $content);
105 return $result;
106 }
107
108 private function transmitNews($object, $arr_item)
109 {
110 if(!is_array($arr_item))
111 return;
112
113 $itemTpl = " -
114
115
116
117
118
119 ";
120 $item_str = "";
121 foreach ($arr_item as $item)
122 $item_str .= sprintf($itemTpl, $item['Title'], $item['Description'], $item['PicUrl'], $item['Url']);
123
124 $newsTpl = "
125
126
127 %s
128
129
130 %s
131
132 $item_str
133 ";
134
135 $result = sprintf($newsTpl, $object->FromUserName, $object->ToUserName, time(), count($arr_item));
136 return $result;
137 }
138
139 private function logger($log_content)
140 {
141 }
142 }
143
144
145 ?>




