Advertisement
croc

Discord Webhook Poster

Aug 14th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.25 KB | None | 0 0
  1. <?php
  2.  
  3. // Webhook URL
  4. $url = '';
  5.  
  6. // Fill with the content of the embed
  7. $obj = array (
  8.    'title' => '',
  9.    'description' => '',
  10.    'author' =>
  11.    array (
  12.      'name' => '',
  13.      'icon_url' => '',
  14.    ),
  15.    'color' => 36863,
  16.    'footer' =>
  17.    array (
  18.      'text' => '',
  19.    ),
  20.    'fields' =>
  21.    array (
  22.      0 =>
  23.      array (
  24.        'name' => 'Version',
  25.        'value' => '1.0.0',
  26.        'inline' => false,
  27.      ),
  28.      1 =>
  29.      array (
  30.        'name' => 'Changelog Link',
  31.        'value' => '',
  32.        'inline' => false,
  33.      ),
  34.    ),
  35.  );
  36.  
  37. $payload = array(
  38.    'content' => '',
  39.    'embeds' => array($obj)
  40. );
  41.  
  42. $headers = array(
  43.    'Content-Type' => 'application/json',
  44.    'Content-Length' => strlen(urlencode(json_encode($obj)))
  45. );
  46.  
  47. $curl_handle=curl_init();
  48. curl_setopt($curl_handle, CURLOPT_URL,$url);
  49. curl_setopt($curl_handle, CURLOPT_HTTPHEADER, $headers);
  50. curl_setopt($curl_handle, CURLOPT_POST, true);
  51. curl_setopt($curl_handle, CURLOPT_POSTFIELDS, json_encode($payload));
  52. curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
  53. curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
  54. curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Chrome');
  55. $query = curl_exec($curl_handle);
  56. curl_close($curl_handle);
  57.  
  58. print($query);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement