Gửi tin nhắn Discord

API đơn giản để gửi tin nhắn tới người dùng Discord qua Bot.

Endpoint

POST https://bot2.thainguyenit.vn

Phương thức

POST

Tham số

Ví dụ Request

POST https://bot2.thainguyenit.vn
Content-Type: application/x-www-form-urlencoded

tokenDiscord=YOUR_BOT_TOKEN&chatIdDiscord=USER_ID&message=Hello+word!

Response thành công

{
  "status": "success",
  "message": "Message sent successfully",
  "discord_response": {
    "id": "1234567890",
    "type": 0,
    "content": "Hello word!"
  }
}

Response lỗi

{
  "status": "error",
  "message": "Missing tokenDiscord, chatIdDiscord, or message in POST"
}

Code mẫu PHP gửi request

<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://bot2.thainguyenit.vn/',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS => 'tokenDiscord=YOUR_BOT_TOKEN&chatIdDiscord=USER_ID&message=Hello%20word!',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/x-www-form-urlencoded'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;