From 826e504fb3ed0b864ed22e2f87ac448e863eb309 Mon Sep 17 00:00:00 2001 From: hugy <504650082@qq.com> Date: Sat, 27 May 2023 11:27:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=8E=B7=E5=8F=96=E7=BE=A4=E6=88=90?= =?UTF-8?q?=E5=91=98=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/3.9.2.26.md | 49 +++++++++++++++++++++++++++++++++++++++++++ src/api_route.h | 1 + src/contact_mgr.cc | 38 +++++++++++++++++++++++++++++++++ src/contact_mgr.h | 1 + src/http_handler.cc | 25 ++++++++++++++++++++++ src/wechat_function.h | 8 +++++++ 6 files changed, 122 insertions(+) diff --git a/doc/3.9.2.26.md b/doc/3.9.2.26.md index 5768283..9e5755d 100644 --- a/doc/3.9.2.26.md +++ b/doc/3.9.2.26.md @@ -36,6 +36,7 @@ 57.获取消息语音文件 58.登录二维码 59.邀请入群 +60.获取群/群成员详情 ### 接口文档: @@ -1694,4 +1695,52 @@ 响应: ``` javascript {"code":1,"result":"OK"} +``` + + +#### 60.群/群成员详情** +###### 接口功能 +> 邀请入群 + +###### 接口地址 +> [/api/?type=60](/api/?type=60) + +###### HTTP请求方式 +> POST JSON + +###### 请求参数 +|参数|必选|类型|说明| +|---|---|---|---| +|wxid|string|wxid| + + + +###### 返回字段 +|返回字段|字段类型|说明 | +|---|---|---| +|code|int|返回状态,1成功, 非0失败| +|result|string|成功提示| + + + + +###### 接口示例 +入参: +``` javascript +{ + "wxid":"wxid_8888" +} + +``` +响应: +``` javascript +{ + "account": "lllla", + "code": 1, + "headImage": "", + "nickname": "昵称", + "result": "OK", + "v3": "v3_020b3sssd031xxxxx05@stranger", + "wxid": "wxid_888888" +} ``` \ No newline at end of file diff --git a/src/api_route.h b/src/api_route.h index e226bff..b3643cf 100644 --- a/src/api_route.h +++ b/src/api_route.h @@ -73,6 +73,7 @@ typedef enum HTTP_API_ROUTE { WECHAT_GET_VOICE, WECHAT_GET_QRCODE, WECHAT_INVITE_MEMBERS, + WECHAT_GET_MEMBER_PROFILE, } WECHAT_HTTP_APIS, *PWECHAT_HTTP_APIS; diff --git a/src/contact_mgr.cc b/src/contact_mgr.cc index aba7846..1bc4e77 100644 --- a/src/contact_mgr.cc +++ b/src/contact_mgr.cc @@ -217,4 +217,42 @@ int ContactMgr::AddFriendByWxid(wchar_t *wxid,wchar_t* msg) { } return success; } + + int ContactMgr::GetContactByWxid(wchar_t *wxid,ContactProfile& profile){ + int success = -1; + char buff[0x440] = {0}; + WeChatString pri(wxid); + DWORD contact_mgr_addr = base_addr_ + WX_CONTACT_MGR_OFFSET; + DWORD get_contact_addr = base_addr_ + WX_GET_CONTACT_OFFSET; + DWORD free_contact_addr = base_addr_ + WX_FREE_CONTACT_OFFSET; + __asm { + PUSHAD + PUSHFD + CALL contact_mgr_addr + LEA ECX,buff + PUSH ECX + LEA ECX,pri + PUSH ECX + MOV ECX,EAX + CALL get_contact_addr + POPFD + POPAD + } + success = 0; + profile.wxid = READ_WSTRING(buff, 0x10); + profile.account = READ_WSTRING(buff, 0x24); + profile.v3 = READ_WSTRING(buff, 0x38); + profile.nickname = READ_WSTRING(buff, 0x6C); + profile.head_image = READ_WSTRING(buff, 0x110); + __asm { + PUSHAD + PUSHFD + LEA ECX,buff + CALL free_contact_addr + POPFD + POPAD + } + success = 1; + return success; + } } // namespace wxhelper \ No newline at end of file diff --git a/src/contact_mgr.h b/src/contact_mgr.h index 24de50b..6a630f8 100644 --- a/src/contact_mgr.h +++ b/src/contact_mgr.h @@ -15,6 +15,7 @@ class ContactMgr : public BaseMgr { std::wstring GetContactOrChatRoomNickname(wchar_t* id); int AddFriendByWxid(wchar_t* wxid,wchar_t* msg); int VerifyApply(wchar_t *v3, wchar_t *v4,int permission); + int GetContactByWxid(wchar_t* wxid,ContactProfile& profile); }; } // namespace wxhelper diff --git a/src/http_handler.cc b/src/http_handler.cc index 395a721..7dec252 100644 --- a/src/http_handler.cc +++ b/src/http_handler.cc @@ -591,7 +591,32 @@ string Dispatch(struct mg_connection *c, struct mg_http_message *hm) { ret = ret_data.dump(); break; } + case WECHAT_GET_MEMBER_PROFILE: { + wstring pri_id = GetWStringParam(j_param, "wxid"); + ContactProfile profile; + int success = + g_context.contact_mgr->GetContactByWxid(WS2LPWS(pri_id),profile); + if(success==1){ + json ret_data = { + {"code", success}, + {"result", "OK"}, + {"account", Utils::WstringToUTF8(profile.account)}, + {"headImage", Utils::WstringToUTF8(profile.head_image)}, + {"nickname", Utils::WstringToUTF8(profile.nickname)}, + {"v3", Utils::WstringToUTF8(profile.v3)}, + {"wxid", Utils::WstringToUTF8(profile.wxid)}, + }; + ret = ret_data.dump(); + } else { + json ret_data = {{"result", "ok"}, {"code", success}}; + ret = ret_data.dump(); + } + + break; + } default: + json ret_data = {{"result", "ERROR"}, {"msg", "not support api"}}; + ret = ret_data.dump(); break; } diff --git a/src/wechat_function.h b/src/wechat_function.h index 34e644c..eeaca13 100644 --- a/src/wechat_function.h +++ b/src/wechat_function.h @@ -778,4 +778,12 @@ struct Unkown{ DWORD field5= 0; DWORD field6= 0; }; + +struct ContactProfile{ + std::wstring wxid; + std::wstring account; + std::wstring v3; + std::wstring nickname; + std::wstring head_image; +}; #endif \ No newline at end of file