Untitled
unknown
plain_text
2 years ago
1.4 kB
6
Indexable
void sendweb(const char* webhookURL, const char* message) {
SSL_load_error_strings();
SSL_library_init();
ERR_load_BIO_strings();
OpenSSL_add_all_algorithms();
const char* hostname = "discord.com";
const char* port = "443";
SSL_CTX* ctx = SSL_CTX_new(SSLv23_client_method());
BIO* bio = BIO_new_ssl_connect(ctx);
BIO_set_conn_hostname(bio, (hostname + std::string(":") + port).c_str());
if (BIO_do_connect(bio) <= 0) {
// Handle connection error
ERR_print_errors_fp(stderr);
BIO_free_all(bio);
SSL_CTX_free(ctx);
return;
}
// Perform SSL handshake
if (BIO_do_handshake(bio) <= 0) {
// Handle handshake error
ERR_print_errors_fp(stderr);
BIO_free_all(bio);
SSL_CTX_free(ctx);
return;
}
std::string request = "POST /api/webhooks/" + std::string(webhookURL) + " HTTP/1.1\r\n"
"Host: discord.com\r\n"
"Content-Type: application/json\r\n"
"Content-Length: " + std::to_string(strlen(message)) + "\r\n"
"\r\n" + std::string(message);
BIO_puts(bio, request.c_str());
// Receive and print response
char response[1024];
int bytesRead = BIO_read(bio, response, sizeof(response));
// Handle response as needed
BIO_free_all(bio);
SSL_CTX_free(ctx);
}
Editor is loading...
Leave a Comment