ex_wechat v0.1.3 ExWechat.Message

Parse wechat message from Plug.Conn && Generate wechat message from Map.

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(msg)

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

  build_message(%{
    from: "userid",
    to: "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.

parser_message(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]