View Source WeChat.ServerMessage.EventHelper (wechat v0.16.0)
微信推送消息处理
API Docs
增加 saxy 依赖
注意: 公众号推送消息格式为 xml
def deps do
[
{:wechat, "~> x.x", hex: :wechat_sdk},
{:saxy, "~> x.x"}
]
end
Summary
Functions
验证消息的确来自微信服务器
处理第三方平台推送通知
parse xml format event message for work
parse xml format event message for official_account
Types
@type data_type() :: :plaqin_text | :encrypted_xml | :encrypted_json
@type encrypt_content() :: String.t()
@type json() :: map()
@type json_string() :: String.t()
@type nonce() :: String.t()
@type signature() :: String.t()
@type status() :: Plug.Conn.status()
@type xml() :: map()
@type xml_string() :: String.t()
Functions
@spec check_msg_signature?(encrypt_content(), params(), WeChat.token()) :: boolean()
@spec check_signature?(params(), WeChat.token()) :: boolean()
验证消息的确来自微信服务器
@spec decrypt_json_msg(encrypt_content(), params(), WeChat.client()) :: {:ok, :encrypted, json_string()} | {:error, String.t()}
@spec decrypt_json_msg( encrypt_content(), params(), WeChat.appid(), WeChat.token(), WeChat.ServerMessage.Encryptor.aes_key() ) :: {:ok, :encrypted, json_string()} | {:error, String.t()}
@spec decrypt_xml_msg(encrypt_content(), params(), WeChat.client()) :: {:ok, :encrypted, xml_string()} | {:error, String.t()}
@spec decrypt_xml_msg( encrypt_content(), params(), WeChat.appid(), WeChat.token(), WeChat.ServerMessage.Encryptor.aes_key() ) :: {:ok, :encrypted, xml_string()} | {:error, String.t()}
@spec encrypt_xml_msg(xml_string(), timestamp(), WeChat.client()) :: String.t()
@spec encrypt_xml_msg( xml_string(), timestamp(), WeChat.client(), WeChat.Work.Agent.t() ) :: String.t()
@spec encrypt_xml_msg( xml_string(), timestamp(), WeChat.appid(), WeChat.token(), WeChat.ServerMessage.Encryptor.aes_key() ) :: String.t()
处理第三方平台推送通知
@spec parse_json_event(params(), body :: String.t(), WeChat.client()) :: {:ok, data_type(), json()} | {:error, String.t()}
@spec parse_work_xml_event( params(), body :: String.t() | map(), WeChat.client(), WeChat.Work.Agent.t() ) :: {:ok, data_type(), xml()} | {:error, String.t()}
parse xml format event message for work
@spec parse_xml_event(params(), body :: String.t() | map(), WeChat.client()) :: {:ok, data_type(), xml()} | {:error, String.t()}
parse xml format event message for official_account
@spec reply_msg( data_type(), xml_string(), timestamp(), WeChat.client(), WeChat.Work.Agent.t() ) :: String.t()