def parse_data(self, data, msg_signature=None, timestamp=None, nonce=None):
        """
        解析微信服务器发送过来的数据并保存类中
        :param data: HTTP Request 的 Body 数据
        :param msg_signature: EncodingAESKey 的 msg_signature
        :param timestamp: EncodingAESKey 用时间戳
        :param nonce: EncodingAESKey 用随机数
        :raises ParseError: 解析微信服务器数据错误, 数据不合法
        """
        result = {}
        if isinstance(data, six.text_type):  # unicode to str(PY2), str to bytes(PY3)
            data = data.encode('utf-8')

        if self.conf.encrypt_mode == 'safe':
            if not (msg_signature and timestamp and nonce):
                raise ParseError('must provide msg_signature/timestamp/nonce in safe encrypt mode')

            data = self.conf.crypto.decrypt_message(
                msg=data,
                msg_signature=msg_signature,
                timestamp=timestamp,
                nonce=nonce,
            )
        try:
            xml = XMLStore(xmlstring=data)
        except Exception:
            raise ParseError()

        result = xml.xml2dict
        result['raw'] = data
        result['type'] = result.pop('MsgType').lower()

        message_type = MESSAGE_TYPES.get(result['type'], UnknownMessage)
        self.__message = message_type(result)
        self.__is_parse = True
def parse_data(self, data, msg_signature=None, timestamp=None, nonce=None):
        """
        解析微信服务器发送过来的数据并保存类中
        :param data: HTTP Request 的 Body 数据
        :param msg_signature: EncodingAESKey 的 msg_signature
        :param timestamp: EncodingAESKey 用时间戳
        :param nonce: EncodingAESKey 用随机数
        :raises ParseError: 解析微信服务器数据错误, 数据不合法
        """
        result = {}
        if isinstance(data, six.text_type):  # unicode to str(PY2), str to bytes(PY3)
            data = data.encode('utf-8')

        if self.conf.encrypt_mode == 'safe':
            if not (msg_signature and timestamp and nonce):
                raise ParseError('must provide msg_signature/timestamp/nonce in safe encrypt mode')

            data = self.conf.crypto.decrypt_message(
                msg=data,
                msg_signature=msg_signature,
                timestamp=timestamp,
                nonce=nonce,
            )
        try:
            xml = XMLStore(xmlstring=data)
        except Exception:
            raise ParseError()

        result = xml.xml2dict
        result['raw'] = data
        result['type'] = result.pop('MsgType').lower()

        message_type = MESSAGE_TYPES.get(result['type'], UnknownMessage)
        self.__message = message_type(result)
        self.__is_parse = True
def parse_data ( self , data , msg_signature = None , timestamp = None , nonce = None ) : result = { } if isinstance ( data , six . text_type ) : # unicode to str(PY2), str to bytes(PY3) data = data . encode ( 'utf-8' ) if self . conf . encrypt_mode == 'safe' : if not ( msg_signature and timestamp and nonce ) : raise ParseError ( 'must provide msg_signature/timestamp/nonce in safe encrypt mode' ) data = self . conf . crypto . decrypt_message ( msg = data , msg_signature = msg_signature , timestamp = timestamp , nonce = nonce , ) try : xml = XMLStore ( xmlstring = data ) except Exception : raise ParseError ( ) result = xml . xml2dict result [ 'raw' ] = data result [ 'type' ] = result . pop ( 'MsgType' ) . lower ( ) message_type = MESSAGE_TYPES . get ( result [ 'type' ] , UnknownMessage ) self . __message = message_type ( result ) self . __is_parse = True
解析微信服务器发送过来的数据并保存类中
        :param data: HTTP Request 的 Body 数据
        :param msg_signature: EncodingAESKey 的 msg_signature
        :param timestamp: EncodingAESKey 用时间戳
        :param nonce: EncodingAESKey 用随机数
        :raises ParseError: 解析微信服务器数据错误, 数据不合法
解析微信服务器发送过来的数据并保存类中 : param data : HTTP Request 的 Body 数据 : param msg_signature : EncodingAESKey 的 msg_signature : param timestamp : EncodingAESKey 用时间戳 : param nonce : EncodingAESKey 用随机数 : raises ParseError : 解析微信服务器数据错误 数据不合法