forked from silenceper/wechat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
basic.go
52 lines (44 loc) · 1.26 KB
/
basic.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
package basic
import (
"fmt"
openContext "github.com/silenceper/wechat/v2/openplatform/context"
"github.com/silenceper/wechat/v2/util"
)
const (
getAccountBasicInfoURL = "https://api.weixin.qq.com/cgi-bin/account/getaccountbasicinfo"
)
//Basic 基础信息设置
type Basic struct {
*openContext.Context
appID string
}
//NewBasic new
func NewBasic(opContext *openContext.Context, appID string) *Basic {
return &Basic{Context: opContext, appID: appID}
}
//AccountBasicInfo 基础信息
type AccountBasicInfo struct {
util.CommonError
}
//GetAccountBasicInfo 获取小程序基础信息
//reference:https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/Mini_Programs/Mini_Program_Information_Settings.html
func (basic *Basic) GetAccountBasicInfo() (*AccountBasicInfo, error) {
ak, err := basic.GetAuthrAccessToken(basic.AppID)
if err != nil {
return nil, err
}
url := fmt.Sprintf("%s?access_token=%s", getAccountBasicInfoURL, ak)
data, err := util.HTTPGet(url)
if err != nil {
return nil, err
}
result := &AccountBasicInfo{}
if err := util.DecodeWithError(data, result, "account/getaccountbasicinfo"); err != nil {
return nil, err
}
return result, nil
}
//modify_domain设置服务器域名
//TODO
//func (encryptor *Basic) modifyDomain() {
//}