|
5 | 5 | import com.alibaba.fastjson2.JSONReader; |
6 | 6 | import com.meteor.wechatbc.entitiy.SendMessage; |
7 | 7 | import com.meteor.wechatbc.entitiy.contact.Contact; |
| 8 | +import com.meteor.wechatbc.entitiy.contact.GetBatchContact; |
8 | 9 | import com.meteor.wechatbc.entitiy.message.SentMessage; |
9 | 10 | import com.meteor.wechatbc.entitiy.session.BaseRequest; |
10 | 11 | import com.meteor.wechatbc.entitiy.synccheck.SyncCheckResponse; |
|
26 | 27 | import java.io.ByteArrayInputStream; |
27 | 28 | import java.io.File; |
28 | 29 | import java.io.IOException; |
| 30 | +import java.util.ArrayList; |
| 31 | +import java.util.List; |
29 | 32 | import java.util.concurrent.TimeUnit; |
30 | 33 |
|
31 | 34 | /** |
@@ -168,6 +171,39 @@ public JSONObject getContact() { |
168 | 171 | } |
169 | 172 |
|
170 | 173 |
|
| 174 | + @Override |
| 175 | + public JSONObject batchGetContactDetail(List<GetBatchContact> queryContactList) { |
| 176 | + if (queryContactList == null || queryContactList.isEmpty()) { |
| 177 | + queryContactList = new ArrayList<>(); |
| 178 | + } |
| 179 | + |
| 180 | + Integer count = queryContactList.size(); |
| 181 | + Session session = weChatClient.getWeChatCore().getSession(); |
| 182 | + BaseRequest baseRequest = session.getBaseRequest(); |
| 183 | + HttpUrl httpUrl = URL.BASE_URL.newBuilder() |
| 184 | + .encodedPath(URL.BATCH_GET_CONTACT) |
| 185 | + .addQueryParameter("skey", baseRequest.getSkey()) |
| 186 | + .addQueryParameter("pass_ticket", baseRequest.getPassTicket()) |
| 187 | + .addQueryParameter("rr", String.valueOf(System.currentTimeMillis())) |
| 188 | + .addQueryParameter("type", "ex") |
| 189 | + .build(); |
| 190 | + |
| 191 | + JSONObject jsonObject = new JSONObject(); |
| 192 | + jsonObject.put("Count", count); |
| 193 | + jsonObject.put("List", queryContactList); |
| 194 | + Request request = BASE_REQUEST.newBuilder().url(httpUrl) |
| 195 | + .post(RequestBody.create(mediaType, jsonObject.toString())) |
| 196 | + .build(); |
| 197 | + try ( |
| 198 | + Response response = okHttpClient.newCall(request).execute(); |
| 199 | + ) { |
| 200 | + String body = response.body().string(); |
| 201 | + return JSON.parseObject(body); |
| 202 | + } catch (IOException e) { |
| 203 | + throw new RuntimeException(e); |
| 204 | + } |
| 205 | + } |
| 206 | + |
171 | 207 | @Override |
172 | 208 | public SentMessage sendMessage(String toUserName, String content) { |
173 | 209 | Session session = weChatClient.getWeChatCore().getSession(); |
|
0 commit comments