Current section

Files

Jump to
exwechat lib wechat material.ex
Raw

lib/wechat/material.ex

defmodule ExWechat.Material do
@moduledoc """
微信素材管理
"""
alias ExWechat.Util
@doc """
### 获取素材列表
在新增了永久素材后,开发者可以分类型获取永久素材的列表。素材的类型:
- 图片 (image)
- 视频 (video)
- 语音 (voice)
- 图文 (news)
### 例子
```
query(:image)
```
"""
@spec query(:image | :video | :voice | :news) :: {:ok, list} | {:error, map}
def query(type) do
params = %{type: type, offset: 0, count: 20} |> Poison.encode!
~s"https://api.weixin.qq.com/cgi-bin/material/batchget_material?access_token=#{ExWechat.token()}"
|> HTTPoison.post!(params, [Util.content_type(:json)])
|> Util.parse_resp
|> Util.check_wechat_resp
end
end