68 lines
1.6 KiB
Go
68 lines
1.6 KiB
Go
package business
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
"fmt"
|
|
"ocean/utils"
|
|
)
|
|
|
|
const checkQrconnect = "https://sso.oceanengine.com/check_qrconnect/?fp&aid=1402&language=zh&account_sdk_source=web"
|
|
|
|
type checkQrconnectResponse struct {
|
|
Data struct {
|
|
Extra string `json:"extra"`
|
|
RedirectURL string `json:"redirect_url,omitempty"`
|
|
Status string `json:"status"`
|
|
} `json:"data"`
|
|
Description string `json:"description"`
|
|
ErrorCode int `json:"error_code"`
|
|
Message string `json:"message"`
|
|
}
|
|
|
|
type FormatCheckQrconnectResponse struct {
|
|
RedirectURL string `json:"redirect_url,omitempty"`
|
|
Status string `json:"status"`
|
|
}
|
|
|
|
func (c *Client) CheckQrconnect(xbogus, msToken, token string) (data *FormatCheckQrconnectResponse, err error) {
|
|
|
|
url := fmt.Sprintf("%s&X-Bogus=%s&msToken=%s", checkQrconnect, xbogus, msToken)
|
|
|
|
header := map[string]string{
|
|
"Origin": "https://business.oceanengine.com",
|
|
"Referer": "https://business.oceanengine.com",
|
|
}
|
|
|
|
cookie := map[string]string{}
|
|
|
|
form := map[string]string{
|
|
"fp": "",
|
|
"aid": "1402",
|
|
"account_sdk_source": "web",
|
|
"service": "https://business.oceanengine.com/nbs/api/bm/user/login_transfer?appKey=51",
|
|
"token": token,
|
|
}
|
|
|
|
resp, _, err := utils.PostForm(url, header, cookie, form)
|
|
|
|
if err != nil {
|
|
return
|
|
}
|
|
|
|
result := &checkQrconnectResponse{}
|
|
|
|
err = json.Unmarshal(resp, result)
|
|
|
|
if err != nil && result.ErrorCode != 0 {
|
|
return nil, errors.New(result.Description)
|
|
}
|
|
|
|
format := &FormatCheckQrconnectResponse{
|
|
RedirectURL: result.Data.RedirectURL,
|
|
Status: result.Data.Status,
|
|
}
|
|
|
|
return format, nil
|
|
}
|