CREONIX

Glua | Discord WebHook | PHP PART 2

Jun 24th, 2022 (edited)
723
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.62 KB | None | 0 0
  1. <?php
  2.  
  3. $discord_token = $_POST["discord_token"];
  4.  
  5. $text = $_POST["text"];
  6.  
  7. $name = $_POST["name"];
  8.  
  9. $json_data = json_encode([
  10.  
  11.     "content" => $text,
  12.    
  13.     "username" => $name,
  14.  
  15. ], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
  16.  
  17. $ch = curl_init( $discord_token );
  18. curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
  19. curl_setopt( $ch, CURLOPT_POST, 1);
  20. curl_setopt( $ch, CURLOPT_POSTFIELDS, $json_data);
  21. curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
  22. curl_setopt( $ch, CURLOPT_HEADER, 0);
  23. curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
  24.  
  25. $response = curl_exec( $ch );
  26. curl_close( $ch );
Add Comment
Please, Sign In to add comment