LibWechat.Core (lib_wechat v0.4.0)
View SourceLibWechat 核心模块,提供对各 API 模块功能的访问。
此模块作为 LibWechat 库的核心接口层,负责将调用委托给相应的具体 API 模块。 为了保持向后兼容性,此模块提供了与原有调用方式相同的接口,但内部实现已重构为更模块化的结构。
Summary
Functions
获取小程序 scheme 码。
获取应用实例的配置信息。
获取 access_token。
获取用户手机号。
获取小程序 URL Link。
小程序登录凭证校验。
检查文本是否含有违法违规内容。
启动 LibWechat 核心模块的 Agent 进程。
下发统一消息。
Types
@type err_t() :: {:error, LibWechat.Error.t()}
@type ok_t(m) :: {:ok, m}
Functions
@spec generate_scheme(module(), binary(), LibWechat.Typespecs.dict()) :: {:ok, LibWechat.Typespecs.dict()} | err_t()
获取小程序 scheme 码。
委托给 LibWechat.API.MiniProgram.WxaCode.generate_scheme/3 处理。
参数
name- 应用实例名称token- 接口调用凭证payload- 请求参数
返回值
{:ok, map()}- 获取成功,返回 scheme 信息{:error, error}- 获取失败
获取应用实例的配置信息。
参数
name- 应用实例名称
返回值
config- 配置信息的关键字列表
@spec get_access_token(module()) :: {:ok, LibWechat.Typespecs.dict()} | err_t()
获取 access_token。
委托给 LibWechat.API.Auth.AccessToken.get/1 处理。
参数
name- 应用实例名称
返回值
{:ok, %{"access_token" => token, "expires_in" => expires}}- 获取成功{:error, error}- 获取失败
@spec get_phone_number(module(), binary(), binary()) :: {:ok, LibWechat.Typespecs.dict()} | err_t()
获取用户手机号。
委托给 LibWechat.API.MiniProgram.PhoneNumber.get/3 处理。
参数
name- 应用实例名称token- 接口调用凭证code- 手机号获取凭证
返回值
{:ok, map()}- 获取成功,返回手机号信息{:error, error}- 获取失败
@spec get_unlimited_wxacode(module(), binary(), LibWechat.Typespecs.dict()) :: {:ok, binary()} | err_t()
获取小程序码。
委托给 LibWechat.API.MiniProgram.WxaCode.get_unlimited/3 处理。
参数
name- 应用实例名称token- 接口调用凭证payload- 请求参数
返回值
{:ok, binary()}- 获取成功,返回图片二进制数据{:error, error}- 获取失败
@spec get_urllink(module(), binary(), LibWechat.Typespecs.dict()) :: {:ok, LibWechat.Typespecs.dict()} | err_t()
获取小程序 URL Link。
委托给 LibWechat.API.MiniProgram.WxaCode.get_urllink/3 处理。
参数
name- 应用实例名称token- 接口调用凭证payload- 请求参数
返回值
{:ok, map()}- 获取成功,返回 URL Link 信息{:error, error}- 获取失败
@spec jscode_to_session(module(), binary()) :: {:ok, LibWechat.Typespecs.dict()} | err_t()
小程序登录凭证校验。
委托给 LibWechat.API.Auth.AccessToken.code2session/2 处理。
参数
name- 应用实例名称code- 小程序登录时获取的 code
返回值
{:ok, %{"openid" => openid, "session_key" => session_key}}- 获取成功{:error, error}- 获取失败
@spec msg_sec_check(module(), binary(), LibWechat.Typespecs.dict()) :: {:ok, LibWechat.Typespecs.dict()} | err_t()
检查文本是否含有违法违规内容。
委托给 LibWechat.API.MiniProgram.Security.msg_sec_check/3 处理。
参数
name- 应用实例名称token- 接口调用凭证payload- 请求参数
返回值
{:ok, map()}- 检测成功,返回检测结果{:error, error}- 检测失败
启动 LibWechat 核心模块的 Agent 进程。
参数
name- 应用实例名称finch- Finch HTTP 客户端实例config- 配置信息
返回值
{:ok, pid}- 启动成功{:error, reason}- 启动失败
@spec subscribe_send(module(), binary(), LibWechat.Typespecs.dict()) :: {:ok, LibWechat.Typespecs.dict()} | err_t()
发送订阅消息。
委托给 LibWechat.API.Message.Subscribe.send/3 处理。
参数
name- 应用实例名称token- 接口调用凭证payload- 请求参数
返回值
{:ok, map()}- 发送成功,返回结果{:error, error}- 发送失败
@spec uniform_send(module(), binary(), LibWechat.Typespecs.dict()) :: {:ok, LibWechat.Typespecs.dict()} | err_t()
下发统一消息。
委托给 LibWechat.API.Message.Subscribe.uniform_send/3 处理。
参数
name- 应用实例名称token- 接口调用凭证payload- 请求参数
返回值
{:ok, map()}- 发送成功,返回结果{:error, error}- 发送失败