Skip to content

Commit

Permalink
fix: 部分微信号因为cookie的domain所属为wx.qq.com无法正常登录
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorOSS committed Mar 1, 2024
1 parent 25deccb commit d71a8cc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.meteor</groupId>
<artifactId>wechat-bc</artifactId>
<version>1.1.4-SNAPSHOT</version>
<version>1.1.5-SNAPSHOT</version>

<distributionManagement>
<repository>
Expand Down
4 changes: 2 additions & 2 deletions release_info.info
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=v1.1.4
DESCRIPTION=feat: PayMessage
VERSION=v1.1.5
DESCRIPTION=fix: 部分微信号无法登录


10 changes: 10 additions & 0 deletions src/main/java/com/meteor/wechatbc/launch/login/WeChatLogin.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.meteor.wechatbc.launch.login.model.QRCodeResponse;
import com.meteor.wechatbc.util.BaseConfig;
import com.meteor.wechatbc.util.HttpUrlHelper;
import com.meteor.wechatbc.util.URL;
import okhttp3.*;
import org.apache.logging.log4j.Logger;

Expand Down Expand Up @@ -116,6 +117,15 @@ private BaseRequest getLoginInfo(QRCodeResponse qrCodeResponse) {
baseRequest.setInitCookie(cookies);
// 设置登录设备ID
baseRequest.setDeviceId(BaseConfig.getDeviceId());

Cookie ck = cookies.get(0);

// 获取cookie的 domain 所属域名
URL.setBASE_URL(new HttpUrl.Builder()
.scheme("https")
.host(ck.domain())
.build());

for (Cookie cookie : cookies) {
String name = cookie.name();
if (name.startsWith("webwx_data_ticket")) {
Expand Down
9 changes: 7 additions & 2 deletions src/main/java/com/meteor/wechatbc/util/URL.java
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
package com.meteor.wechatbc.util;

import lombok.Setter;
import okhttp3.HttpUrl;

/**
* 微信相关接口
*/
public class URL {

public final static HttpUrl BASE_URL = new HttpUrl.Builder()


@Setter public static HttpUrl BASE_URL = new HttpUrl.Builder()
.scheme("https")
.host("wx2.qq.com")
.host("wx.qq.com")
.build();



public final static String WXINIT = "/cgi-bin/mmwebwx-bin/webwxinit";
public final static String SYNCCHECK = "/cgi-bin/mmwebwx-bin/synccheck";

Expand Down

0 comments on commit d71a8cc

Please sign in to comment.