WeChat.ServerMessage.EventHandler (wechat v0.2.0)
微信推送消息处理
API Docs
Link to this section Summary
Link to this section Types
Link to this type
data_type()
Specs
data_type() :: :plaqin_text | :encrypted_xml | :encrypted_json
Link to this type
encrypt_content()
Specs
encrypt_content() :: String.t()
Link to this type
handle_event_fun()
Specs
handle_event_fun() :: (WeChat.client(), message :: map() -> handle_event_fun_return())
事件处理回调方法
Link to this type
handle_event_fun_return()
Specs
handle_event_fun_return() :: {:reply, reply_msg :: xml_string(), timestamp()} | {:reply, reply_msg :: json_string()} | :ok | :ignore | :retry | :error | {:error, any()}
事件处理回调返回值
返回值说明:
{:reply, xml_string, timestamp}
: 被动回复消息,仅限于公众号/第三方平台{:reply, json_string}
: 被动回复消息,仅限小程序推送消息:ok
: 成功:ignore
: 成功:retry
: 选择重试,微信服务器会重试三次:error
: 返回错误,微信服务器会重试三次{:error, any}
: 返回错误,微信服务器会重试三次
Link to this type
json()
Specs
json() :: map()
Link to this type
json_string()
Specs
json_string() :: String.t()
Link to this type
nonce()
Specs
nonce() :: String.t()
Link to this type
signature()
Specs
signature() :: String.t()
Link to this type
status()
Specs
status() :: Plug.Conn.status()
Link to this type
xml()
Specs
xml() :: map()
Link to this type
xml_string()
Specs
xml_string() :: String.t()
Link to this section Functions
Link to this function
check_signature?(params, client)
Specs
check_signature?(params(), WeChat.client()) :: boolean()
验证消息的确来自微信服务器
Link to this function
decode_json_msg(encrypt_content, signature, nonce, timestamp, client)
Specs
decode_json_msg( encrypt_content(), signature(), nonce(), timestamp(), WeChat.client() ) :: {:ok, :encrypted, json_string()} | {:error, String.t()}
Link to this function
decode_xml_msg(encrypt_content, signature, nonce, timestamp, client)
Specs
decode_xml_msg( encrypt_content(), signature(), nonce(), timestamp(), WeChat.client() ) :: {:ok, :encrypted, xml_string()} | {:error, String.t()}
Link to this function
encode_xml_msg(xml_string, timestamp, client)
Specs
encode_xml_msg(xml_string(), timestamp(), WeChat.client()) :: String.t()
Link to this function
handle_component_message(message)
处理第三方平台推送通知
Link to this function
handle_event_json(params, body, client)
Specs
handle_event_json(params(), body :: String.t(), WeChat.client()) :: {:ok, data_type(), json()} | {:error, String.t()}
Link to this function
handle_event_xml(params, body, client)
Specs
handle_event_xml(params(), body :: String.t(), WeChat.client()) :: {:ok, data_type(), xml()} | {:error, String.t()}
Link to this function
handle_get(query_params, client)
Specs
handle_get(params(), WeChat.client()) :: {status(), String.t()}
验证消息的确来自微信服务器
Link to this function
handle_post(conn, client, handle_event_fun)
Specs
handle_post(Plug.Conn.t(), WeChat.client(), handle_event_fun()) :: {status(), String.t()}
接受事件推送