def test_get_weather(self): data = reply.process_reply(ElementTree.fromstring(""" <xml> <ToUserName><![CDATA[toUser]]></ToUserName> <FromUserName><![CDATA[fromUser]]></FromUserName> <CreateTime>1348831860</CreateTime> <MsgType><![CDATA[text]]></MsgType> <Content><![CDATA[天气]]></Content> <MsgId>1234567890123456</MsgId> </xml> """)) print(data) data = reply.process_reply(ElementTree.fromstring(""" <xml> <ToUserName><![CDATA[toUser]]></ToUserName> <FromUserName><![CDATA[fromUser]]></FromUserName> <CreateTime>1348831860</CreateTime> <MsgType><![CDATA[text]]></MsgType> <Content><![CDATA[南京天气]]></Content> <MsgId>1234567890123456</MsgId> </xml> """)) print(data)
def process_post(request): signature = request.GET['signature'] timestamp = request.GET['timestamp'] nonce = request.GET['nonce'] if not validate.is_weixin_serve(signature, timestamp, nonce): return HttpResponse("False") xml_data = ElementTree.fromstring(request.body) return HttpResponse(reply.process_reply(xml_data))