新增搜索微信

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

No files matched your search

+37
View File
@@ -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;
}
+2 -1
View File
@@ -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
+1
View File
@@ -16,6 +16,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call,
break;
}
case DLL_PROCESS_DETACH: {
http_close();
break;
}
}
+26
View File
@@ -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