2
I’m trying to make a script that sends news, updates, to a server Discord, for this I need to use the Webhooks. I’ve already set up the whole system, including already working.
But the system I made just sends text, and I would like to do this system to send also along with the text, two images, to get a nice layout for the news.
In the PHP I am using the following code to send messages to Discord:
<?php
function postToDiscord($message) {
$data = array("content" => $message, "username" => "News");
$curl = curl_init("https://discordapp.com/api/webhooks/2225546.......");
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
return curl_exec($curl);
}
?>
Only this way only sends text. Staying so there in Discord:
But I wanted the news to come out like this:
Can you handle me? I want to send these images from the top and the footer along with the text, so that the news appear with a more beautiful look.
For you to better understand how the system works Add the Test Server you create on Discord and the website that sends the news to Discord:
Discord: https://discord.gg/6nGdjnz Posting site: http://diegodevphp.esy.es/