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