I have been trying to figure out how to send an attachment in webhooks. I've been trying hours but cannot figure it out. I've been reading the this but I still haven't had much link. I've also been reading the docs but struggling to understand. Can anyone assist me?
<pre><?php
$url = "WEBHOOK URL HERE";
$headers = [ 'Content-Type: multipart/form-data; charset=utf-8' ];
$POST = [
// Message
"content" => "Hello World!",
// Username
"username" => "testuser",
// File upload
"file" => curl_file_create("image.gif", 'image/gif', 'image')
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($POST));
$response = curl_exec($ch);
var_dump($response);
I'm getting the error
"{"message": "Cannot send an empty message", "code": 50006}"