We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
版本: 0.4.8
config.exs:
config :wechat, adapter_opts: {Wechat.Adapters.Sandbox, []}, httpoison_opts: [recv_timeout: 300_000]
demo:
defmodule MyApp.Wechat do use Wechat, otp_app: :my_app def users do client() |> Wechat.User.get() end end
若使用 MyApp.Wechat.client()会输出:
MyApp.Wechat.client()
%Wechat.Client{ access_token: nil, appid: "wx00000000000", encoding_aes_key: nil, endpoint: "http://************", secret: "***********************", token: nil }
access_token一直为nil
nil
每次请求微信的api, MyApp.Wechat.access_token 每次都不同,会消耗完access_token的限制次数。
MyApp.Wechat.access_token
看过源码后,加入了Map.put(:access_token, access_token())就能解决access_token每次都需要重新获取的问题。
Map.put(:access_token, access_token())
access_token
实现:
defmodule BeautyMotherland.Wechat do use Wechat, otp_app: :beauty_motherland def users do client() |> Map.put(:access_token, access_token()) |> Wechat.User.get() end def sign_jsapi(url) do client() |> Map.put(:access_token, access_token()) |> Wechat.Client.sign_jsapi(url) end def jssdk(url, js_api_list \\ []) do %{timestamp: timestamp, noncestr: nonce, signature: signature} = sign_jsapi(url) %{ jsApiList: js_api_list, appId: client().appid, timestamp: timestamp, nonceStr: nonce, signature: signature } end def user_info(openid) do client() |> Map.put(:access_token, access_token()) |> Wechat.User.info(openid) end end
The text was updated successfully, but these errors were encountered:
多谢反馈,我检查一下
Sorry, something went wrong.
No branches or pull requests
版本: 0.4.8
config.exs:
demo:
若使用
MyApp.Wechat.client()
会输出:access_token一直为
nil
每次请求微信的api,
MyApp.Wechat.access_token
每次都不同,会消耗完access_token的限制次数。看过源码后,加入了
Map.put(:access_token, access_token())
就能解决access_token
每次都需要重新获取的问题。实现:
The text was updated successfully, but these errors were encountered: