ex_wechat v0.1.7 Wechat.Message.XmlMessage

Module to deal with xml message.

Summary

Functions

Generate message for wechat. You can find what you need for generate message from the template file

Get xml data from Plug.Conn ant then parse xml wechat message to Map. You can get this message by use

Functions

build(message, time \\ &TimeHelper.current_unix_time/0)

Generate message for wechat. You can find what you need for generate message from the template file.

  build(fromusername: "userid", tousername: "server_app_id",
    msgtype: "text", content: "Hello World!"})

will generate:

  <xml>
  <ToUserName><![CDATA[userid]]></ToUserName>
  <FromUserName><![CDATA[server_app_id]]></FromUserName>
  <CreateTime>1478449547</CreateTime>
  <MsgType><![CDATA[text]]></MsgType>
  <Content><![CDATA[Hello World!]]></Content> </xml>

This method will automaticlly check the msgtype, and choose the right template to render message.

parse(xml_msg)

Get xml data from Plug.Conn ant then parse xml wechat message to Map. You can get this message by use:

  conn.assigns[:message]