-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
50 lines (42 loc) · 1.48 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <Windows.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <winhttp.h>
#pragma comment(lib, "winhttp.lib")
int main() {
HINTERNET hSession = WinHttpOpen(L"Fontesie/1.0",
WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
WINHTTP_NO_PROXY_NAME,
WINHTTP_NO_PROXY_BYPASS,
0);
HINTERNET hConnect = WinHttpConnect(hSession,
L"discordapp.com",
INTERNET_DEFAULT_HTTPS_PORT,
0);
HINTERNET hRequest = WinHttpOpenRequest(hConnect,
L"POST",
L"/api/webhooks/webhook-id/webhook-token",
NULL,
WINHTTP_NO_REFERER,
WINHTTP_DEFAULT_ACCEPT_TYPES,
WINHTTP_FLAG_SECURE);
std::string title = "Title";
std::string desc = "Description";
std::string color = "16711680"; // Decimal color
std::string request_body = "{\"username\": \"github.com/Fontesie\",\"content\": null,\"embeds\": [{\"title\": \"" + title + "\",\"description\": \"" + desc + "\",\"footer\": {\"text\": \"github.com/fontesie\"},\"color\": " + color + " }], \"attachments\": []}";
BOOL bResults = WinHttpSendRequest(hRequest,
L"Content-Type: application/json\r\n",
(DWORD)-1L,
(LPVOID)request_body.c_str(),
(DWORD)request_body.length(),
(DWORD)request_body.length(),
0);
if (bResults) {
WinHttpReceiveResponse(hRequest, NULL);
}
WinHttpCloseHandle(hRequest);
WinHttpCloseHandle(hConnect);
WinHttpCloseHandle(hSession);
return 0;
}