forked from l306287405/wechat3rd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
open_api.go
65 lines (59 loc) · 1.83 KB
/
open_api.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package wechat3rd
import "github.com/l306287405/wechat3rd/core"
//清空api的调用quota
//https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/openApi/clear_quota.html
func (s *Server) ClearQuota(authorizerAccessToken string, appId string) (resp *core.Error) {
var (
u = CGIUrl + "/clear_quota?"
req = &struct {
AppId string `json:"appid"`
}{AppId: appId}
)
resp = &core.Error{}
resp.Err(core.PostJson(s.AuthToken2url(u, authorizerAccessToken), req, resp))
return
}
type QuotaGetResp struct {
core.Error
Quota struct {
DailyLimit int `json:"daily_limit"`
Used int `json:"used"`
Remain int `json:"remain"`
} `json:"quota"`
}
//查询openApi调用quota
//https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/openApi/get_api_quota.html
func (s *Server) QuotaGet(authorizerAccessToken string, cgiPath string) (resp *QuotaGetResp) {
var (
u = CGIUrl + "/openapi/quota/get?"
req = &struct {
CgiPath string `json:"cgi_path"`
}{CgiPath: cgiPath}
)
resp = &QuotaGetResp{}
resp.Err(core.PostJson(s.AuthToken2url(u, authorizerAccessToken), req, resp))
return
}
type RidGetResp struct {
core.Error
Request struct {
InvokeTime int64 `json:"invoke_time"`
CostInMs int `json:"cost_in_ms"`
RequestUrl string `json:"request_url"`
RequestBody string `json:"request_body"`
ResponseBody string `json:"response_body"`
} `json:"request"`
}
//查询rid信息
//https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/openApi/get_rid_info.html
func (s *Server) RidGet(authorizerAccessToken string, rid string) (resp *RidGetResp) {
var (
u = CGIUrl + "/openapi/rid/get?"
req = &struct {
Rid string `json:"rid"`
}{Rid: rid}
)
resp = &RidGetResp{}
resp.Err(core.PostJson(s.AuthToken2url(u, authorizerAccessToken), req, resp))
return
}