+ APICookie

This commit is contained in:
gazebo
2019-07-24 16:18:11 +08:00
parent 74c07ba61e
commit 32b53c9c9e
14 changed files with 168 additions and 121 deletions

View File

@@ -140,21 +140,8 @@ var (
monthSaleNumReg = regexp.MustCompile(`(\d+)([千|万])`)
)
func (a *API) SetStoreCookie(storeCookie string) {
a.locker.Lock()
defer a.locker.Unlock()
a.storeCookie = storeCookie
}
func (a *API) GetStoreCookie() string {
a.locker.RLock()
defer a.locker.RUnlock()
return a.storeCookie
}
func (a *API) AccessStorePage(fullURL string, params map[string]interface{}, isPost bool) (retVal map[string]interface{}, err error) {
storeCookie := a.GetStoreCookie()
if storeCookie == "" {
if a.GetCookieCount() == 0 {
return nil, fmt.Errorf("需要设置Store Cookie才能使用此方法")
}
err = platformapi.AccessPlatformAPIWithRetry(a.client,
@@ -170,14 +157,7 @@ func (a *API) AccessStorePage(fullURL string, params map[string]interface{}, isP
if err != nil {
return nil
}
request.AddCookie(&http.Cookie{
Name: accessStorePageCookieName,
Value: storeCookie,
})
request.AddCookie(&http.Cookie{
Name: accessStorePageCookieName2,
Value: storeCookie,
})
a.FillRequestCookies(request)
return request
},
a.config,