src/main/java/io/github/biezhi/wechat/api/WeChatApiImpl.java
public void loadGroupList() {
        log.info("加载群聊信息");

        // 群账号
        List<Map<String, String>> list = new ArrayList<>(groupUserNames.size());

        for (String groupUserName : groupUserNames) {
            Map<String, String> map = new HashMap<>(2);
            map.put("UserName", groupUserName);
            map.put("EncryChatRoomId", "");
            list.add(map);
        }

        String url = String.format("%s/webwxbatchgetcontact?type=ex&r=%s&pass_ticket=%s",
                bot.session().getUrl(), System.currentTimeMillis() / 1000, bot.session().getPassTicket());

        // 加载群信息
        JsonResponse jsonResponse = this.client.send(new JsonRequest(url).post().jsonBody()
                .add("BaseRequest", bot.session().getBaseRequest())
                .add("Count", groupUserNames.size())
                .add("List", list)
        );

        this.groupList = WeChatUtils.fromJson(WeChatUtils.toJson(jsonResponse.toJsonObject().getAsJsonArray("ContactList")), new TypeToken<List<Account>>() {});
    }
public void loadGroupList() {
        log.info("加载群聊信息");

        // 群账号
        List<Map<String, String>> list = new ArrayList<>(groupUserNames.size());

        for (String groupUserName : groupUserNames) {
            Map<String, String> map = new HashMap<>(2);
            map.put("UserName", groupUserName);
            map.put("EncryChatRoomId", "");
            list.add(map);
        }

        String url = String.format("%s/webwxbatchgetcontact?type=ex&r=%s&pass_ticket=%s",
                bot.session().getUrl(), System.currentTimeMillis() / 1000, bot.session().getPassTicket());

        // 加载群信息
        JsonResponse jsonResponse = this.client.send(new JsonRequest(url).post().jsonBody()
                .add("BaseRequest", bot.session().getBaseRequest())
                .add("Count", groupUserNames.size())
                .add("List", list)
        );

        this.groupList = WeChatUtils.fromJson(WeChatUtils.toJson(jsonResponse.toJsonObject().getAsJsonArray("ContactList")), new TypeToken<List<Account>>() {});
    }
public void loadGroupList ( ) { log . info ( "加载群聊信息"); // 群账号 List < Map < String , String > > list = new ArrayList <> ( groupUserNames . size ( ) ) ; for ( String groupUserName : groupUserNames ) { Map < String , String > map = new HashMap <> ( 2 ) ; map . put ( "UserName" , groupUserName ) ; map . put ( "EncryChatRoomId" , "" ) ; list . add ( map ) ; } String url = String . format ( "%s/webwxbatchgetcontact?type=ex&r=%s&pass_ticket=%s" , bot . session ( ) . getUrl ( ) , System . currentTimeMillis ( ) / 1000 , bot . session ( ) . getPassTicket ( ) ) ; // 加载群信息 JsonResponse jsonResponse = this . client . send ( new JsonRequest ( url ) . post ( ) . jsonBody ( ) . add ( "BaseRequest" , bot . session ( ) . getBaseRequest ( ) ) . add ( "Count" , groupUserNames . size ( ) ) . add ( "List" , list ) ) ; this . groupList = WeChatUtils . fromJson ( WeChatUtils . toJson ( jsonResponse . toJsonObject ( ) . getAsJsonArray ( "ContactList" ) ) , new TypeToken < List < Account > > ( ) { } ) ; }
加载群信息
加载群信息