WeChat.Storage.Adapter.DefaultComponentClient (elixir_wechat v0.4.0) View Source
For component
application.
defmodule MyClient do
use WeChat.Component,
adapter_storage: {:default, "http://localhost:4000"},
appid: "MyComponentAppID"
end
The above equals as below
defmodule MyClient do
use WeChat.Component,
adapter_storage: {
WeChat.Storage.Adapter.DefaultComponentClient,
"http://localhost:4000"
},
appid: "MyComponentAppID"
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 authorizer access_token
Request
- method: POST http://localhost:4000/refresh/access_token
- body: %{"appid" => "Your3rdComponentAppID", "authorizer_appid" => "YourAuthorizerAppID", "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
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
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`