From 9e5dce93f03a13574498ca9e29dddcca5ccc06f4 Mon Sep 17 00:00:00 2001 From: hugy <504650082@qq.com> Date: Fri, 17 Feb 2023 14:46:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=90=9C=E7=B4=A2=E5=BE=AE?= =?UTF-8?q?=E4=BF=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 60 +++++++++++++++++++++++++++++++++++++++++++++++ src/api.cc | 37 +++++++++++++++++++++++++++++ src/api.h | 3 ++- src/dllMain.cc | 1 + src/wechat_data.h | 26 ++++++++++++++++++++ 5 files changed, 126 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4096ab6..af99860 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,7 @@ vcpkg 11.hook图片 12.取消hook图片 17.删除好友 +19.通过手机或qq查找微信 20.通过wxid添加好友 25.获取群成员 26.获取群成员昵称 @@ -508,6 +509,65 @@ vcpkg {"code":0,"result":"OK"} ``` +#### 19.通过手机或qq查找微信** +###### 接口功能 +> 通过手机或qq查找微信 + +###### 接口地址 +> [/api/?type=19](/api/?type=19) + +###### HTTP请求方式 +> POST JSON + +###### 请求参数 +|参数|必选|类型|说明| +|---|---|---|---| +|keyword |true |string| 手机或qq | + + +###### 返回字段 +|返回字段|字段类型|说明 | +|---|---|---| +|code|int|返回状态,1成功, -1失败| +|result|string|成功提示| +|userInfo|object|用户信息| +|  bigImage|string|大头像| +|  smallImage|string|小头像| +|  city|string|城市| +|  nation|string|民族| +|  nickname|string|昵称| +|  province|string|省| +|  sex|number|性别| +|  signature|string|签名| +|  v2|string|v2| +|  v3|string|v3| + +###### 接口示例 +入参: +``` javascript +{ + "keyword":"131111111" +} +``` +响应: +``` javascript +{ + "code": 1, + "result": "OK", + "userInfo": { + "bigImage": "http://wx.qlogo.cn/mmhead/ver_1/7NIHQAyXeaAPa7Vd7p122mKxgETJwoAiaERdk1sSyOyfnLLQOfElw4G9I32QkZzh7bGfZr2lg0OIQE1Az3cUwtWaLUM79Q/0", + "city": "", + "nation": "", + "nickname": "昵称", + "province": "", + "sex": 0, + "signature": "", + "smallImage": "http://wx.qlogo.cn/mmhead/ver_1/7NIHQAyXeaAPa7Vd7p4KR3vxiasmKxgETJwoAiaER23QE6G5mLBcdBQkZzh7bGfZr2lg0OIQE1Az3cUwtWaLUM79Q/132", + "v2": "wxid_12333", + "v3": "v3_020b3826fd0301000000000098ca23832239a3dba12f95f6b60a0536a1adb6b40fc4086288f46c0b89e6c4eb70c34f118c7b4b6a6845144843b088f0077e406507f821068571289b36c4158a8ac47ec41ae47bee65e9@stranger" + } +} +``` diff --git a/src/api.cc b/src/api.cc index 434827c..602524c 100644 --- a/src/api.cc +++ b/src/api.cc @@ -22,6 +22,7 @@ #include "pat.h" #include "confirm_receipt.h" #include "sns.h" +#include "search_contact.h" #pragma comment(lib, "ws2_32.lib") using namespace std; @@ -321,6 +322,26 @@ void api_handle(mg_http_message *hm, struct mg_connection *c, string &ret) { break; } case WECHAT_CONTACT_SEARCH_BY_NET: { + wstring keyword = get_http_req_param(hm, j_param, "keyword", is_post); + UserInfo *user = nullptr; + int success = SearchContactNetScene(WS2LW(keyword), &user); + json ret_data = {{"code", success}, {"result", "OK"}}; + if (user) { + json info = { + {"bigImage", unicode_to_utf8(user->big_image)}, + {"smallImage", unicode_to_utf8(user->small_image)}, + {"city", unicode_to_utf8(user->city)}, + {"nation", unicode_to_utf8(user->nation)}, + {"nickname", unicode_to_utf8(user->nickname)}, + {"province", unicode_to_utf8(user->province)}, + {"sex", user->sex}, + {"signature", unicode_to_utf8(user->signature)}, + {"v2", unicode_to_utf8(user->v2)}, + {"v3", unicode_to_utf8(user->v3)}, + }; + ret_data["userInfo"] = info; + } + ret = ret_data.dump(); break; } case WECHAT_CONTACT_ADD_BY_WXID: { @@ -682,4 +703,20 @@ int http_start(int port) { kHttpThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)http_server, (LPVOID)port, NULL, 0); return 0; +} + +int http_close() { + if (!kHttpRuning) { + return 1; + } + kHttpRuning = false; + if (kHttpThread) { + WaitForSingleObject(kHttpThread, -1); + CloseHandle(kHttpThread); + kHttpThread = NULL; + } + UnHookRecvMsg(); + UnHookImg(); + UnHookSearchContact(); + return 0; } \ No newline at end of file diff --git a/src/api.h b/src/api.h index 970d9e0..94b9c50 100644 --- a/src/api.h +++ b/src/api.h @@ -74,5 +74,6 @@ typedef enum WECHAT_HTTP_APISTag *PWECHAT_HTTP_APIS; -int http_start(int port); +extern "C" __declspec(dllexport) int http_start(int port); +extern "C" __declspec(dllexport) int http_close(); #endif \ No newline at end of file diff --git a/src/dllMain.cc b/src/dllMain.cc index 42cbf5e..355e03d 100644 --- a/src/dllMain.cc +++ b/src/dllMain.cc @@ -16,6 +16,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, break; } case DLL_PROCESS_DETACH: { + http_close(); break; } } diff --git a/src/wechat_data.h b/src/wechat_data.h index 6fc8d18..6f0d63e 100644 --- a/src/wechat_data.h +++ b/src/wechat_data.h @@ -155,4 +155,30 @@ struct SelfInfoInner{ std::string data_save_path; std::string current_data_path; }; + +struct UserInfo { + int error_code; + wchar_t *keyword; + int keyword_len; + wchar_t *v3; + int v3_len; + wchar_t *nickname; + int nickname_len; + wchar_t *signature; + int signature_len; + wchar_t *v2; + int v2_len; + wchar_t *nation; + int nation_len; + wchar_t *province; + int province_len; + wchar_t *city; + int city_len; + wchar_t *big_image; + int big_image_len; + wchar_t *small_image; + int small_image_len; + DWORD sex; + BOOL over; +}; #endif