-
Notifications
You must be signed in to change notification settings - Fork 0
/
categorysettablelist.go
47 lines (40 loc) · 1.22 KB
/
categorysettablelist.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
41
42
43
44
45
46
47
/**
* Created by GoLand.
* User: 姜伟
* Date: 2020/1/10 0010
* Time: 23:47
*/
package category
import (
"github.com/a07061625/gompf/mpf"
"github.com/a07061625/gompf/mpf/api"
"github.com/a07061625/gompf/mpf/api/wx"
"github.com/a07061625/gompf/mpf/mpconstant/errorcode"
)
// 可设置的所有类目
type categorySettableList struct {
wx.BaseWxOpen
appId string // 应用ID
}
func (csl *categorySettableList) SendRequest() api.APIResult {
csl.ReqURI = "https://api.weixin.qq.com/cgi-bin/wxopen/getallcategories?access_token=" + wx.NewUtilWx().GetOpenAuthorizeAccessToken(csl.appId)
client, req := csl.GetRequest()
resp, result := csl.SendInner(client, req, errorcode.WxOpenRequestGet)
if resp.RespCode > 0 {
return result
}
respData, _ := mpf.JSONUnmarshalMap(resp.Content)
errCode, ok := respData["errcode"]
if ok && (errCode.(int) == 0) {
result.Data = respData
} else {
result.Code = errorcode.WxOpenRequestGet
result.Msg = respData["errmsg"].(string)
}
return result
}
func NewCategorySettableList(appId string) *categorySettableList {
csl := &categorySettableList{wx.NewBaseWxOpen(), ""}
csl.appId = appId
return csl
}