fish2018/pansou · error
获取Cookie失败
Error message
获取Cookie失败: %w
What it means
checkQRLoginStatus (plugin/qqpd/qqpd.go:1808) wraps failures from p.fetchFullCookie(uin, ptsigx, setCookieStr) as '获取Cookie失败: %w'. After QR login succeeds and ptsigx/uin are extracted, the plugin exchanges them at QQ's check_sig endpoint for the full cookie set; any network error or non-success status there surfaces as this error.
Solutions
- Check the underlying error printed by the [QQPD] log line to distinguish network vs parsing failure
- Retry the check_login poll promptly after QR scan — ptsigx is short-lived
- Verify outbound connectivity to QQ's check_sig domain (ssl.ptlogin2.qq.com)
- Re-issue a fresh QR code if the sign exchange keeps failing
Example fix
// before
cookie, err := p.fetchFullCookie(uin, ptsigx, setCookieStr)
if err != nil {
return nil, fmt.Errorf("获取Cookie失败: %w", err)
}
// after
cookie, err := p.fetchFullCookie(uin, ptsigx, setCookieStr)
if err != nil {
return nil, fmt.Errorf("获取Cookie失败 (uin=%s): %w", p.maskQQ(uin), err)
} Defensive patterns
Strategy: retry
Try / catch
user, err := p.checkQRLoginStatus(qrsig)
if err != nil {
if strings.Contains(err.Error(), "获取Cookie失败") {
// ptsigx likely expired or check_sig request failed; restart QR flow
return p.restartQRFlow()
}
return err
} Prevention
- Call check_login immediately after the user scans to avoid ptsigx expiry
- Ensure stable connectivity to ssl.ptlogin2.qq.com
- Apply the same cookie jar across ptqrlogin and check_sig requests
- Add a fallback that re-issues a QR code after N cookie-exchange failures
When it happens
Trigger: handleCheckLogin -> checkQRLoginStatus: the ptqrlogin response succeeded and ptsigx/uin were parsed, but the follow-up fetchFullCookie HTTP request fails (transport error, non-2xx, or missing expected cookies in the response).
Common situations: ptsigx expired because the check_sig request happened too late, QQ rate-limiting or blocking the client IP, network outage, or QQ changing the check_sig response shape so the plugin can't assemble the cookie.
Understand the failure class
Background: "API request failed": what wrapped HTTP errors from external APIs mean and how to find the real cause — this error's family across 29 libraries.
Related errors
AI-assisted analysis of fish2018/pansou@beaa561337 (2026-09-07).
Data as JSON: /api/errors/c1ab290bb1d4b584.
Report an issue: GitHub.
Appendix: source
Thrown at plugin/qqpd/qqpd.go:1808
return &LoginResult{Status: "expired"}, nil
}
if strings.Contains(bodyStr, "登录成功") {
// 提取ptsigx和uin
ptsigx, uin, err := p.extractLoginInfo(bodyStr)
if err != nil {
fmt.Printf("[QQPD] 提取登录信息失败: %v, 响应: %s\n", err, bodyStr)
return nil, fmt.Errorf("提取登录信息失败: %w", err)
}
// 获取完整Cookie(传递ptqrlogin返回的所有Set-Cookie)
allSetCookies := resp.Header.Values("Set-Cookie")
setCookieStr := strings.Join(allSetCookies, "; ")
cookie, err := p.fetchFullCookie(uin, ptsigx, setCookieStr)
if err != nil {
fmt.Printf("[QQPD] 获取Cookie失败: %v\n", err)
return nil, fmt.Errorf("获取Cookie失败: %w", err)
}
// 生成脱敏QQ号
qqMasked := p.maskQQ(uin)
if DebugLog {
fmt.Printf("[QQPD] 登录成功!QQ: %s, Cookie长度: %d, 包含keys: ", qqMasked, len(cookie))
cookies := parseCookieString(cookie)
keys := make([]string, 0, len(cookies))
for k := range cookies {
keys = append(keys, k)
}
fmt.Printf("%v\n", keys)
}
return &LoginResult{
Status: "success",
Cookie: cookie,View on GitHub (pinned to beaa561337)