50 lines
1.5 KiB
Go
50 lines
1.5 KiB
Go
package core
|
|
|
|
import "github.com/goWxHook/goWxHook/utils/json"
|
|
|
|
type GetMiniProgramCodeRequest struct {
|
|
Appid string `json:"appid"`
|
|
}
|
|
|
|
type GetMiniProgramCodeResponseData struct {
|
|
AppIconUrl string `json:"appIconUrl"`
|
|
AppName string `json:"appName"`
|
|
BaseResponse struct {
|
|
ErrMsg struct {
|
|
String string `json:"string"`
|
|
} `json:"errMsg"`
|
|
Ret int `json:"ret"`
|
|
} `json:"baseResponse"`
|
|
Code string `json:"code"`
|
|
JsApiBaseResponse struct {
|
|
Errcode int `json:"errcode"`
|
|
Errmsg string `json:"errmsg"`
|
|
} `json:"jsApiBaseResponse"`
|
|
LiftSpan int `json:"liftSpan"`
|
|
OpenId string `json:"openId"`
|
|
ScopeList []interface{} `json:"scopeList"`
|
|
SessionKey string `json:"sessionKey"`
|
|
SessionTicket string `json:"sessionTicket"`
|
|
Signature string `json:"signature"`
|
|
State string `json:"state"`
|
|
}
|
|
|
|
type GetMiniProgramCodeResponse struct {
|
|
Data GetMiniProgramCodeResponseData `json:"data"`
|
|
Type int `json:"type"`
|
|
}
|
|
|
|
// GetMiniProgramCode 获取小程序授权Code
|
|
func (w *WxApi) GetMiniProgramCode(request GetMiniProgramCodeRequest) (*GetMiniProgramCodeResponseData, error) {
|
|
resp, err := w.internalCall(MtGetMiniProgramCodeMsg, 60, MtGetMiniProgramCodeMsg, request, nil)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var rdata GetMiniProgramCodeResponse
|
|
err = json.Unmarshal([]byte(resp), &rdata)
|
|
if err != nil {
|
|
return nil, WxError{-1, err.Error()}
|
|
}
|
|
return &rdata.Data, nil
|
|
}
|