mirror of
https://gitcode.com/JianFeeeee/ModelRouter.git
synced 2026-11-09 18:57:21 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ec5e6dd57c |
@ -33,7 +33,10 @@ func newLoomyHarness(t *testing.T) *loomyHarness {
|
|||||||
switch {
|
switch {
|
||||||
case strings.HasPrefix(r.URL.Path, "/connect/qrconnect"):
|
case strings.HasPrefix(r.URL.Path, "/connect/qrconnect"):
|
||||||
w.Header().Set("Content-Type", "text/html")
|
w.Header().Set("Content-Type", "text/html")
|
||||||
fmt.Fprint(w, `<html><script>var uuid = "UUID-TEST-1";</script></html>`)
|
// 夹具必须用**真实微信页面的形态**:uuid 内嵌在
|
||||||
|
// <img class="js_qrcode_img" src="/connect/qrcode/<uuid>"/>。
|
||||||
|
// 用别的形态(如 var uuid = "...")测出来的正则不是生产要用的那条。
|
||||||
|
fmt.Fprint(w, `<html><img class="js_qrcode_img" src="/connect/qrcode/UUID-TEST-1"/></html>`)
|
||||||
case strings.HasPrefix(r.URL.Path, "/connect/l/qrconnect"):
|
case strings.HasPrefix(r.URL.Path, "/connect/l/qrconnect"):
|
||||||
n := atomic.AddInt32(&h.polls, 1)
|
n := atomic.AddInt32(&h.polls, 1)
|
||||||
w.Header().Set("Content-Type", "text/plain")
|
w.Header().Set("Content-Type", "text/plain")
|
||||||
@ -159,7 +162,7 @@ func TestLoomyWechatPollBehavior(t *testing.T) {
|
|||||||
hh := newLoomyHarness(t)
|
hh := newLoomyHarness(t)
|
||||||
hh.ts.Config.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
hh.ts.Config.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
if strings.HasPrefix(r.URL.Path, "/connect/qrconnect") {
|
if strings.HasPrefix(r.URL.Path, "/connect/qrconnect") {
|
||||||
fmt.Fprint(w, `<script>var uuid = "U";</script>`)
|
fmt.Fprint(w, `<img src="/connect/qrcode/U">`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Fprintf(w, "window.wx_errcode=%s;", tc.errcode)
|
fmt.Fprintf(w, "window.wx_errcode=%s;", tc.errcode)
|
||||||
|
|||||||
@ -575,13 +575,17 @@ local PLATFORMS = {
|
|||||||
-- 403=用户取消;402=二维码失效
|
-- 403=用户取消;402=二维码失效
|
||||||
flow = "wechat-poll",
|
flow = "wechat-poll",
|
||||||
wechat = {
|
wechat = {
|
||||||
|
-- appid / redirect_uri 照参考常量(原写的 appid 是我编的,上游不认);
|
||||||
|
-- 末尾 `#wechat_redirect` 是微信要求的固定片段,缺它对某些客户端会跳错页。
|
||||||
auth_url = "https://open.weixin.qq.com/connect/qrconnect"
|
auth_url = "https://open.weixin.qq.com/connect/qrconnect"
|
||||||
.. "?appid=wx16e5c2b8e0c0e1f2&scope=snsapi_login&response_type=code"
|
.. "?appid=wx18d60be432287cf8&scope=snsapi_login&response_type=code"
|
||||||
.. "&redirect_uri=https%3A%2F%2Floomy.xunfei.cn%2Foauth%2Fwechat%2Fcallback&state={state}",
|
.. "&redirect_uri=https%3A%2F%2Floomy.xunfei.cn%2Foauth%2Fwechat%2Fcallback"
|
||||||
|
.. "&state={state}#wechat_redirect",
|
||||||
qr_url = "https://open.weixin.qq.com/connect/qrcode/{uuid}",
|
qr_url = "https://open.weixin.qq.com/connect/qrcode/{uuid}",
|
||||||
poll_url = "https://long.open.weixin.qq.com/connect/l/qrconnect",
|
poll_url = "https://long.open.weixin.qq.com/connect/l/qrconnect",
|
||||||
|
-- 逐字照参考 WECHAT_UA(微信对空 UA / 爬虫 UA 可能拒绝)
|
||||||
user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
|
user_agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36"
|
||||||
.. " (KHTML, like Gecko) Chrome/120.0 Safari/537.36",
|
.. " (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",
|
||||||
account_base = "https://account.xfyun.cn",
|
account_base = "https://account.xfyun.cn",
|
||||||
bind_path = "/login/thirdAccount/bind/auth",
|
bind_path = "/login/thirdAccount/bind/auth",
|
||||||
access_key_id = "2thryby66wxi53sk",
|
access_key_id = "2thryby66wxi53sk",
|
||||||
@ -2157,10 +2161,12 @@ function plugin.start_login(req)
|
|||||||
return { status = 200, json = out }
|
return { status = 200, json = out }
|
||||||
end
|
end
|
||||||
local html = resp.body or ""
|
local html = resp.body or ""
|
||||||
-- 主正则 + 兜底(含 uuid 的查询串)
|
-- 两条路径互为兜底(照参考 extractLoomyWechatUuid 的正则):
|
||||||
local uuid = html:match('uuid%s*=%s*"([^"]+)"')
|
-- 主:<img class="js_qrcode_img" src="/connect/qrcode/<uuid>"/>
|
||||||
or html:match("uuid%s*=%s*'([^']+)'")
|
-- 兜底:var fordevtool = "…/connect/l/qrconnect?uuid=<uuid>"
|
||||||
or html:match("[?&]uuid=([%w%-_]+)")
|
-- ⚠️ 无需执行 JS —— 这是本方案能脱离浏览器的基础。
|
||||||
|
local uuid = html:match("/connect/qrcode/([%w_%-=+/]+)")
|
||||||
|
or html:match("l/qrconnect%?uuid=([%w_%-=+/]+)")
|
||||||
if not uuid or uuid == "" then
|
if not uuid or uuid == "" then
|
||||||
sess.state = "failed"
|
sess.state = "failed"
|
||||||
out.error = "微信授权页未包含二维码 uuid(页面结构可能已变化)"
|
out.error = "微信授权页未包含二维码 uuid(页面结构可能已变化)"
|
||||||
|
|||||||
Reference in New Issue
Block a user