View Source WeChat.Storage.Adapter.DefaultClient (elixir_wechat v0.4.6)
For common
application.
defmodule MyClient do
use WeChat,
adapter_storage: {:default, "http://localhost:4000"},
appid: "MyAppID"
end
The above equals as below
defmodule MyClient do
use WeChat,
adapter_storage: {
WeChat.Storage.Adapter.DefaultClient,
"http://localhost:4000"
},
appid: "MyAppID"
end
When uses the {:default, "MyHubBaseURL"}
, there requires some HTTP API functions are provided by the hub web app server,
let's take "MyHubBaseURL" as "http://localhost:4000" for example.
refresh-access-token
Refresh access token
Request
- method: POST http://localhost:4000/refresh/access_token
- body: %{"appid" => "MyAppID", "access_token" => "CurrentExpiryAccessToken"}
- body format: json
Response
- success body: %{"access_token" => "...", "expires_in" => integer(), "timestamp" => integer()}
- error body: any content is acceptable will be return back into `WeChat.Error`
fetch-access-token
Fetch access token
Request
- method: GET http://localhost:4000/client/access_token
- query string: appid="MyAppID"
Response
- success body: %{"access_token" => "...", "expires_in" => integer(), "timestamp" => integer()}
- error body: any error content is acceptable will be return back into `WeChat.Error`
fetch-jsapi-ticket-card-ticket
Fetch jsapi-ticket/card-ticket
Request
- method: GET http://localhost:4000/client/ticket
- query string: appid="MyAppID"&type=jsapi or appid="MyAppID"&type=wx_card
Response
- success body: %{"ticket" => "...", "expires_in" => integer(), timestamp => integer(), "type" => "jsapi" | "wx_card"}
- error body: any error content is acceptable will be return back into `WeChat.Error`