|
|
|
@ -1,13 +1,13 @@
|
|
|
|
|
package wechatopen
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
|
|
|
|
"errors"
|
|
|
|
|
"net/http"
|
|
|
|
|
"strconv"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
// ServeHttpAuthorizerAppid 授权跳转
|
|
|
|
|
func (c *Client) ServeHttpAuthorizerAppid(r *http.Request) (resp CgiBinComponentApiQueryAuthResponse, agentUserId string, err error) {
|
|
|
|
|
func (c *Client) ServeHttpAuthorizerAppid(ctx context.Context, r *http.Request) (resp CgiBinComponentApiQueryAuthResponse, agentUserId string, err error) {
|
|
|
|
|
var (
|
|
|
|
|
query = r.URL.Query()
|
|
|
|
|
|
|
|
|
@ -25,34 +25,10 @@ func (c *Client) ServeHttpAuthorizerAppid(r *http.Request) (resp CgiBinComponent
|
|
|
|
|
return resp, agentUserId, errors.New("找不到过期时间参数")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
info := c.CgiBinComponentApiQueryAuth(authCode)
|
|
|
|
|
info := c.CgiBinComponentApiQueryAuth(ctx, authCode)
|
|
|
|
|
if info.Result.AuthorizationInfo.AuthorizerAppid == "" {
|
|
|
|
|
return resp, agentUserId, errors.New("获取失败")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return info.Result, agentUserId, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ToFloat64 string到float64
|
|
|
|
|
func ToFloat64(s string) float64 {
|
|
|
|
|
i, _ := strconv.ParseFloat(s, 64)
|
|
|
|
|
return i
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ToInt64 string到int64
|
|
|
|
|
func ToInt64(s string) int64 {
|
|
|
|
|
i, err := strconv.ParseInt(s, 10, 64)
|
|
|
|
|
if err == nil {
|
|
|
|
|
return i
|
|
|
|
|
}
|
|
|
|
|
return int64(ToFloat64(s))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ToUint string到uint64
|
|
|
|
|
func ToUint(s string) uint {
|
|
|
|
|
i, err := strconv.ParseUint(s, 10, 64)
|
|
|
|
|
if err == nil {
|
|
|
|
|
return uint(i)
|
|
|
|
|
}
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|