elixir_wechat v0.1.2 WeChat.Adapter.Storage.Client behaviour
The storage adapter specification for WeChat common application.
Since we need to storage(cache) some key data(e.g. access_token
) for invoking WeChat APIs, this module
is used for customizing the persistence when use this library in a :client
side of WeChat common application.
Notice: In the :client
scenario, we only need to implement the minimum functions to automatically append the
required parameters from the persistence.
Writing custom storage adapter
Example for WeChat Official Account Platform application
defmodule MyApp.Storage.Client do
@behaviour WeChat.Adapter.Storage.Client
@impl true
def get_access_token(appid) do
access_token = "Get access_token by appid from your persistence..."
access_token
end
@impl true
def refresh_access_token(appid, access_token) do
# Refresh access_token by appid from your persistence
:ok
end
end
Link to this section Summary
Callbacks
Get access_token of WeChat common application
Refresh access_token of WeChat common application via configured Hub servers
Link to this section Callbacks
Link to this callback
get_access_token(appid)
Get access_token of WeChat common application.
Example
get_access_token(appid)
Link to this callback
refresh_access_token(appid, access_token)
Refresh access_token of WeChat common application via configured Hub servers
Example
refresh_access_token(appid, access_token)