-
Notifications
You must be signed in to change notification settings - Fork 147
/
client.go
40 lines (33 loc) · 1.08 KB
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package material
import (
"github.com/ArtisanCloud/PowerLibs/v2/http/contract"
"github.com/ArtisanCloud/PowerLibs/v2/object"
"github.com/ArtisanCloud/PowerWeChat/v2/src/kernel"
response4 "github.com/ArtisanCloud/PowerWeChat/v2/src/work/media/response"
)
type Client struct {
*kernel.BaseClient
AllowTypes []string
}
func NewClient(app *kernel.ApplicationInterface) (*Client, error) {
baseClient, err := kernel.NewBaseClient(app, nil)
if err != nil {
return nil, err
}
return &Client{
BaseClient: baseClient,
AllowTypes: []string{"image", "voice", "video", "thumb", "news_image"},
}, nil
}
// 获取永久素材图片
// https://developers.weixin.qq.com/doc/offiaccount/Asset_Management/Getting_Permanent_Assets.html
func (comp *Client) Get(mediaID string) (contract.ResponseInterface, error) {
result := ""
header := &response4.ResponseHeaderMedia{}
response, err := comp.RequestRaw("cgi-bin/material/get_material", "POST", &object.HashMap{
"form_params": &object.HashMap{
"media_id": mediaID,
},
}, header, &result)
return response.(contract.ResponseInterface), err
}