新增搜索微信

This commit is contained in:
hugy 2023-02-17 14:46:49 +08:00
parent db5051ae2f
commit 9e5dce93f0
5 changed files with 126 additions and 1 deletions

View File

@ -116,6 +116,7 @@ vcpkg
11.hook图片 11.hook图片
12.取消hook图片 12.取消hook图片
17.删除好友 17.删除好友
19.通过手机或qq查找微信
20.通过wxid添加好友 20.通过wxid添加好友
25.获取群成员 25.获取群成员
26.获取群成员昵称 26.获取群成员昵称
@ -508,6 +509,65 @@ vcpkg
{"code":0,"result":"OK"} {"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"
}
}
```

View File

@ -22,6 +22,7 @@
#include "pat.h" #include "pat.h"
#include "confirm_receipt.h" #include "confirm_receipt.h"
#include "sns.h" #include "sns.h"
#include "search_contact.h"
#pragma comment(lib, "ws2_32.lib") #pragma comment(lib, "ws2_32.lib")
using namespace std; using namespace std;
@ -321,6 +322,26 @@ void api_handle(mg_http_message *hm, struct mg_connection *c, string &ret) {
break; break;
} }
case WECHAT_CONTACT_SEARCH_BY_NET: { 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; break;
} }
case WECHAT_CONTACT_ADD_BY_WXID: { case WECHAT_CONTACT_ADD_BY_WXID: {
@ -683,3 +704,19 @@ int http_start(int port) {
(LPVOID)port, NULL, 0); (LPVOID)port, NULL, 0);
return 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;
}

View File

@ -74,5 +74,6 @@ typedef enum WECHAT_HTTP_APISTag
*PWECHAT_HTTP_APIS; *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 #endif

View File

@ -16,6 +16,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call,
break; break;
} }
case DLL_PROCESS_DETACH: { case DLL_PROCESS_DETACH: {
http_close();
break; break;
} }
} }

View File

@ -155,4 +155,30 @@ struct SelfInfoInner{
std::string data_save_path; std::string data_save_path;
std::string current_data_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 #endif