2020-11-06 17:47:38 +08:00
|
|
|
|
package www
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
2026-06-17 10:05:05 +08:00
|
|
|
|
"strings"
|
|
|
|
|
|
|
2020-11-06 17:47:38 +08:00
|
|
|
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
|
|
|
|
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
|
VERSION = "2020-09-24"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
var HOST requests.Host = requests.Host{
|
|
|
|
|
|
Default: "apisdk.9ooo.cn",
|
|
|
|
|
|
Func: func(s string) string {
|
|
|
|
|
|
var a = map[string]string{
|
|
|
|
|
|
requests.RELEASE: "apisdk.9ooo.cn",
|
|
|
|
|
|
requests.PRE: "apisdk.9ooo.cn",
|
|
|
|
|
|
requests.TEST: "apisdk.9ooo.cn",
|
|
|
|
|
|
}
|
|
|
|
|
|
return a[s]
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type Client struct {
|
|
|
|
|
|
sdk.Client
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-17 10:05:05 +08:00
|
|
|
|
// NewClient 无凭证客户端(用于自带签名的表单接口,如 refreshUserSessionId)
|
|
|
|
|
|
func NewClient() (client *Client, err error) {
|
|
|
|
|
|
client = &Client{}
|
|
|
|
|
|
err = client.Init()
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-11-06 17:47:38 +08:00
|
|
|
|
func NewClientWithAccessKey(accesskey, secrect, source string) (client *Client, err error) {
|
|
|
|
|
|
client = &Client{}
|
|
|
|
|
|
err = client.InitWithAccessKey(accesskey, secrect, source)
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func NewClientWithAliAppcode(accesskey, secrect string, env ...string) (client *Client, err error) {
|
|
|
|
|
|
client = &Client{}
|
|
|
|
|
|
err = client.InitWithAliAppcode(accesskey, secrect, env...)
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (c *Client) GetUserInfo(req *GetPwdRequest) (response *GetPwdResponse, err error) {
|
|
|
|
|
|
response = CreateGetPwdResponse()
|
|
|
|
|
|
err = c.DoAction(req, response)
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2026-06-17 10:05:05 +08:00
|
|
|
|
|
|
|
|
|
|
// RefreshUserSessionID 刷新用户 session(清 www 登录态),返回远端原始响应
|
|
|
|
|
|
func (c *Client) RefreshUserSessionID(uname string) (response string, err error) {
|
|
|
|
|
|
req := CreateRefreshUserSessionIDReq(uname)
|
|
|
|
|
|
resp := CreateRefreshUserSessionIDResp()
|
|
|
|
|
|
err = c.DoAction(req, resp)
|
|
|
|
|
|
if err != nil && strings.Contains(err.Error(), "json Unmarshal:") {
|
|
|
|
|
|
// 远端返回非 JSON(如纯文本),直接取原始响应
|
|
|
|
|
|
return resp.GetHttpContentString(), nil
|
|
|
|
|
|
} else if err != nil {
|
|
|
|
|
|
return "", err
|
|
|
|
|
|
}
|
|
|
|
|
|
return resp.GetHttpContentString(), nil
|
|
|
|
|
|
}
|