LoginRedirect 登录成功回调
(redirectURL string)
| 91 | |
| 92 | // LoginRedirect 登录成功回调 |
| 93 | func LoginRedirect(redirectURL string) (cookie string, err error) { |
| 94 | client := &http.Client{ |
| 95 | CheckRedirect: func(req *http.Request, via []*http.Request) error { |
| 96 | return http.ErrUseLastResponse |
| 97 | }, |
| 98 | } |
| 99 | u, err := url.Parse(redirectURL) |
| 100 | if err != nil { |
| 101 | return |
| 102 | } |
| 103 | values, err := url.ParseQuery(u.RawQuery) |
| 104 | if err != nil { |
| 105 | return |
| 106 | } |
| 107 | redirectReq, err := http.NewRequest("GET", fmt.Sprintf(checkSigURL, values["uin"][0], values["ptsigx"][0]), nil) |
| 108 | if err != nil { |
| 109 | return |
| 110 | } |
| 111 | redirectResp, err := client.Do(redirectReq) |
| 112 | if err != nil { |
| 113 | return |
| 114 | } |
| 115 | defer redirectResp.Body.Close() |
| 116 | for _, v := range redirectResp.Cookies() { |
| 117 | if v.Value != "" { |
| 118 | cookie += v.Name + "=" + v.Value + ";" |
| 119 | } |
| 120 | } |
| 121 | return |
| 122 | } |
| 123 | |
| 124 | // Manager qq空间信息管理 |
| 125 | type Manager struct { |