elixir_wechat v0.1.0 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 delete_access_token(appid, access_token) do
# Delete access_token by appid from your persistence
:ok
end
end
Link to this section Summary
Callbacks
Delete access_token of WeChat common application.
Get access_token of WeChat common application.
Link to this section Callbacks
Link to this callback
delete_access_token(appid, access_token)
Delete access_token of WeChat common application.
Example
delete_access_token(appid, access_token)
Link to this callback
get_access_token(appid)
Get access_token of WeChat common application.
Example
get_access_token(appid)