|
@ -23,6 +23,16 @@ type MiniAppOpenidData struct { |
|
|
Errmsg string `json:"errmsg"` |
|
|
Errmsg string `json:"errmsg"` |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
type MpOpenIdData struct { |
|
|
|
|
|
AccessToken string `json:"access_token"` |
|
|
|
|
|
ExpiresIn int `json:"expires_in"` |
|
|
|
|
|
RefreshToken string `json:"refresh_token"` |
|
|
|
|
|
Openid string `json:"openid"` |
|
|
|
|
|
Scope string `json:"scope"` |
|
|
|
|
|
Errcode int `json:"errcode"` |
|
|
|
|
|
Errmsg string `json:"errmsg"` |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 从微信api取openid |
|
|
* 从微信api取openid |
|
|
*/ |
|
|
*/ |
|
@ -43,7 +53,7 @@ func GetAppOpenid(appid, secret, code string) (AppOpenIdData, error) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 从微信api取openid |
|
|
|
|
|
|
|
|
* 从微信api取小程序openid |
|
|
*/ |
|
|
*/ |
|
|
func GetMiniAppOpenid(appid, secret, code string) (MiniAppOpenidData, error) { |
|
|
func GetMiniAppOpenid(appid, secret, code string) (MiniAppOpenidData, error) { |
|
|
|
|
|
|
|
@ -61,3 +71,23 @@ func GetMiniAppOpenid(appid, secret, code string) (MiniAppOpenidData, error) { |
|
|
|
|
|
|
|
|
return data, err |
|
|
return data, err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 从微信api取公众号openid |
|
|
|
|
|
*/ |
|
|
|
|
|
func GetMpOpenid(appid, secret, code string) (MpOpenIdData, error) { |
|
|
|
|
|
|
|
|
|
|
|
url := fmt.Sprintf(GET_MP_OPENID_API, appid, secret, code) |
|
|
|
|
|
|
|
|
|
|
|
data_byte, err := SendHttp("GET", url, nil) |
|
|
|
|
|
|
|
|
|
|
|
var data MpOpenIdData |
|
|
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return data, err |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
err = json.Unmarshal(data_byte, &data) |
|
|
|
|
|
|
|
|
|
|
|
return data, err |
|
|
|
|
|
} |