Overview

Packages

  • None
  • WxRobot
    • Admin
    • Cmd
    • CoreFunctions
    • Exends
    • Install
    • Table
    • Uninstall
    • WxSDK

Classes

  • ErrorCode
  • PKCS7Encoder
  • Prpcrypt
  • SHA1
  • Weixin_BaseCore
  • WeiXin_SDK
  • Weixin_Template
  • WXBizMsgCrypt
  • WxRobot_Admin
  • WxRobot_Admin_Menu_Extends
  • WxRobot_Admin_Menu_Instro
  • WxRobot_Admin_Menu_Menu
  • WxRobot_Admin_Menu_Records
  • WxRobot_Admin_Menu_Reply
  • WxRobot_Admin_Menu_Setting
  • WxRobot_Admin_Menu_Statistics
  • WxRobot_Cmd
  • WxRobot_Cmd_Event
  • WxRobot_Cmd_Event_User
  • WxRobot_Cmd_Text
  • WxRobot_Extends
  • WxRobot_Install
  • WxRobot_Robot
  • WxRobot_SDK
  • WxRobot_Table_Extends
  • WxRobot_Table_Menu
  • WxRobot_Table_Records
  • WxRobot_Table_Reply
  • WxRobot_Uninstall
  • WxRobot_Wp
  • XMLParse

Functions

  • wx_admin_log
  • wx_is_xml
  • wx_notice_msg
  • wx_parse_xml
  • wx_random_big_pic
  • wx_random_small_pic
  • wx_request_array
  • wx_request_decode
  • wx_request_is_encode
  • wx_request_xml
  • wx_send_encode
  • Overview
  • Package
  • Class
 1: <?php
 2: include_once "errorCode.php";
 3: 
 4: /**
 5:  * XMLParse class
 6:  *
 7:  * 提供提取消息格式中的密文及生成回复消息格式的接口.
 8:  */
 9: class XMLParse
10: {
11: 
12:     /**
13:      * 提取出xml数据包中的加密消息
14:      * @param string $xmltext 待提取的xml字符串
15:      * @return string 提取出的加密消息字符串
16:      */
17:     public function extract($xmltext)
18:     {
19:         try {
20:             $xml = new DOMDocument();
21:             $xml->loadXML($xmltext);
22:             $array_e = $xml->getElementsByTagName('Encrypt');
23:             $array_a = $xml->getElementsByTagName('ToUserName');
24:             $encrypt = $array_e->item(0)->nodeValue;
25:             $tousername = $array_a->item(0)->nodeValue;
26:             return array(0, $encrypt, $tousername);
27:         } catch (Exception $e) {
28:             //print $e . "\n";
29:             return array(ErrorCode::$ParseXmlError, null, null);
30:         }
31:     }
32: 
33:     /**
34:      * 生成xml消息
35:      * @param string $encrypt 加密后的消息密文
36:      * @param string $signature 安全签名
37:      * @param string $timestamp 时间戳
38:      * @param string $nonce 随机字符串
39:      */
40:     public function generate($encrypt, $signature, $timestamp, $nonce)
41:     {
42:         $format = "<xml>
43: <Encrypt><![CDATA[%s]]></Encrypt>
44: <MsgSignature><![CDATA[%s]]></MsgSignature>
45: <TimeStamp>%s</TimeStamp>
46: <Nonce><![CDATA[%s]]></Nonce>
47: </xml>";
48:         return sprintf($format, $encrypt, $signature, $timestamp, $nonce);
49:     }
50: 
51: }
52: 
53: 
54: ?>
API documentation generated by ApiGen