+ APICookie
This commit is contained in:
@@ -298,23 +298,8 @@ type PageShopInfo struct {
|
||||
TakeoutPrice int `json:"takeout_price"`
|
||||
}
|
||||
|
||||
func (a *API) SetStoreCookie(key, value string) {
|
||||
a.locker.Lock()
|
||||
defer a.locker.Unlock()
|
||||
a.storeCookies[key] = value
|
||||
}
|
||||
|
||||
func (a *API) GetStoreCookie(key string) string {
|
||||
a.locker.RLock()
|
||||
defer a.locker.RUnlock()
|
||||
return a.storeCookies[key]
|
||||
}
|
||||
|
||||
func (a *API) AccessStorePage2(subURL string, params map[string]interface{}, isPost bool, cookies map[string]string) (retVal map[string]interface{}, err error) {
|
||||
a.locker.RLock()
|
||||
storeCookieLen := len(a.storeCookies)
|
||||
a.locker.RUnlock()
|
||||
if storeCookieLen == 0 {
|
||||
if a.GetCookieCount() == 0 {
|
||||
return nil, fmt.Errorf("需要设置Store Cookie才能使用此方法")
|
||||
}
|
||||
err = platformapi.AccessPlatformAPIWithRetry(a.client,
|
||||
@@ -327,20 +312,13 @@ func (a *API) AccessStorePage2(subURL string, params map[string]interface{}, isP
|
||||
request.Header.Set("charset", "UTF-8")
|
||||
request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
}
|
||||
a.locker.RLock()
|
||||
for k, v := range a.storeCookies {
|
||||
request.AddCookie(&http.Cookie{
|
||||
Name: k,
|
||||
Value: v,
|
||||
})
|
||||
}
|
||||
a.FillRequestCookies(request)
|
||||
for k, v := range cookies {
|
||||
request.AddCookie(&http.Cookie{
|
||||
Name: k,
|
||||
Value: v,
|
||||
})
|
||||
}
|
||||
a.locker.RUnlock()
|
||||
return request
|
||||
},
|
||||
a.config,
|
||||
|
||||
Reference in New Issue
Block a user