title: Discord webhook embed php curl not working anymore after recent Discord update
body: <p>I've had this Discord webhook for a long time, and everything was alright. Now suddenly it stopped working. The error I'm receiving is:</p>
  
  <blockquote>
    <p>{"message": "Cannot send an empty message", "code": 50006}</p>
  </blockquote>
  
  <p>While the message <strong>and</strong> an embed is set. Here is my code:</p>
  
  <pre><code>$url = "https://discordapp.com/api/webhooks/1234567890/ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  $hookObject = json_encode([
      "content" =&gt; "New sellers application!",
      "username" =&gt; "Roblox",
      "avatar_url" =&gt; "https://www.roblox.com/headshot-thumbnail/image?userId=1&amp;width=420&amp;height=420&amp;format=png",
      "tts" =&gt; false,
      "embeds" =&gt; [
          [
              "title" =&gt; "Accept",
              "type" =&gt; "rich",
              "description" =&gt; "",
              "url" =&gt; "https://google.com/",
              "timestamp" =&gt; gmdate('Y-m-d\TH:i:s', time()),
              "color" =&gt; hexdec( "02b757" ),
              "author" =&gt; [
                  "name" =&gt; "REMOVED",
                  "url" =&gt; "REMOVED"
              ],
              "fields" =&gt; [
                  [
                      "name" =&gt; "Discord",
                      "value" =&gt; "REMOVED#0563",
                      "inline" =&gt; true
                  ],
                  [
                      "name" =&gt; "Amount per week",
                      "value" =&gt; 30000,
                      "inline" =&gt; true
                  ],
                  [
                      "name" =&gt; "Email",
                      "value" =&gt; "REMOVED@example.com",
                      "inline" =&gt; false
                  ],
                  [
                      "name" =&gt; "Name",
                      "value" =&gt; "hehe",
                      "inline" =&gt; true
                  ],
                  [
                      "name" =&gt; "Roblox username",
                      "value" =&gt; "Roblox",
                      "inline" =&gt; true
                  ],
                  [
                      "name" =&gt; "Roblox link",
                      "value" =&gt; "https://www.roblox.com/users/1/profile",
                      "inline" =&gt; false
                  ],
                  [
                      "name" =&gt; "Decline -&gt;",
                      "value" =&gt; "https://google.com/api/decseller?id=JUSTTESTJUSTTEST",
                      "inline" =&gt; false
                  ]
              ]
          ]
      ]
  
  ], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE );
  echo $hookObject;
  $ch = curl_init();
  curl_setopt_array( $ch, [
      CURLOPT_URL =&gt; $url,
      CURLOPT_POST =&gt; true,
      CURLOPT_POSTFIELDS =&gt; $hookObject,
      CURLOPT_HTTPHEADER =&gt; [
          "Length" =&gt; strlen($hookObject),
          "Content-Type" =&gt; "application/json"
      ]
  ]);
  curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_VERBOSE, 1);
  curl_setopt($ch, CURLOPT_HEADER, 1);
  $response = curl_exec( $ch );
  $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
  $header = substr($response, 0, $header_size);
  echo "Body -&gt; ";
  $body = substr($response, $header_size);
  var_dump($body);
  curl_close($ch);
  </code></pre>
  
  <p>That code returns the following:</p>
  
  <pre><code>{"content":"New sellers application!","username":"Roblox","avatar_url":"https://www.roblox.com/headshot-thumbnail/image?userId=1&amp;width=420&amp;height=420&amp;format=png","tts":false,"embeds":[{"title":"Accept","type":"rich","description":"","url":"https://google.com/","timestamp":"2019-12-10T10:23:33","color":178007,"author":{"name":"REMOVED","url":"REMOVED"},"fields":[{"name":"Discord","value":"REMOVED#0563","inline":true},{"name":"Amount per week","value":"30000","inline":true},{"name":"Email","value":"REMOVED@example.com","inline":false},{"name":"Name","value":"hehe","inline":true},{"name":"Roblox username","value":"Roblox","inline":true},{"name":"Roblox link","value":"https://www.roblox.com/users/1/profile","inline":false},{"name":"Decline -&gt;","value":"https://google.com/api/decseller?id=JUSTTESTJUSTTEST","inline":false}]}]}* Expire in 0 ms for 6 (transfer 0x1c517af4500)
  * Expire in 1 ms for 1 (transfer 0x1c517af4500)
  * Expire in 0 ms for 1 (transfer 0x1c517af4500)
  * Expire in 2 ms for 1 (transfer 0x1c517af4500)
  * Expire in 1 ms for 1 (transfer 0x1c517af4500)
  * Expire in 1 ms for 1 (transfer 0x1c517af4500)
  * Expire in 4 ms for 1 (transfer 0x1c517af4500)
  * Expire in 2 ms for 1 (transfer 0x1c517af4500)
  * Expire in 2 ms for 1 (transfer 0x1c517af4500)
  * Expire in 5 ms for 1 (transfer 0x1c517af4500)
  *   Trying 162.159.134.233...
  * TCP_NODELAY set
  * Expire in 149992 ms for 3 (transfer 0x1c517af4500)
  * Expire in 200 ms for 4 (transfer 0x1c517af4500)
  * Connected to discordapp.com (162.159.134.233) port 443 (#0)
  * ALPN, offering h2
  * ALPN, offering http/1.1
  * SSL connection using TLSv1.3 / TLS_AES_256_GCM_SHA384
  * ALPN, server accepted to use h2
  * Server certificate:
  *  subject: OU=Domain Control Validated; OU=PositiveSSL Multi-Domain; CN=ssl711320.cloudflaressl.com
  *  start date: Sep  5 00:00:00 2019 GMT
  *  expire date: Mar 13 23:59:59 2020 GMT
  *  issuer: C=GB; ST=Greater Manchester; L=Salford; O=COMODO CA Limited; CN=COMODO ECC Domain Validation Secure Server CA 2
  *  SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
  * Using HTTP2, server supports multi-use
  * Connection state changed (HTTP/2 confirmed)
  * Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
  * Using Stream ID: 1 (easy handle 0x1c517af4500)
  &gt; POST /api/webhooks/1234567890/ABCDEFGHIJKLMNOPQRSTUVWXYZ HTTP/2
  Host: discordapp.com
  Accept: */*
  Content-Length: 859
  Content-Type: application/x-www-form-urlencoded
  
  * old SSL session ID is stale, removing
  * Connection state changed (MAX_CONCURRENT_STREAMS == 256)!
  * We are completely uploaded and fine
  &lt; HTTP/2 400
  &lt; date: Tue, 10 Dec 2019 10:23:39 GMT
  &lt; content-type: application/json
  &lt; content-length: 58
  &lt; set-cookie: __cfduid=dc03695b32b9ae182c651991a4b50bbe51575973419; expires=Thu, 09-Jan-20 10:23:39 GMT; path=/; domain=.discordapp.com; HttpOnly
  &lt; strict-transport-security: max-age=31536000; includeSubDomains
  &lt; x-ratelimit-bucket: 3cd1f278bd0ecaf11e0d2391374c011d
  &lt; x-ratelimit-limit: 5
  &lt; x-ratelimit-remaining: 4
  &lt; x-ratelimit-reset: 1575973422
  &lt; x-ratelimit-reset-after: 2
  &lt; via: 1.1 google
  &lt; alt-svc: clear
  &lt; cf-cache-status: DYNAMIC
  &lt; expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
  &lt; server: cloudflare
  &lt; cf-ray: 542e812f4e54d905-AMS
  &lt;
  * Connection #0 to host discordapp.com left intact
  Body -&gt; string(58) "{"message": "Cannot send an empty message", "code": 50006}"
  </code></pre>
  
  <p>I asked on Reddit, people couldn't help me there (apparently), and I asked it at the following Discord guilds: </p>
  
  <ul>
  <li>Discord Official API</li>
  <li>The Coding Den</li>
  </ul>
  
  <p>But no one could help there as well, so I'm 100% relying on you guys now, the documentation about the Discord webhooks -> <a href="https://discordapp.com/developers/docs/resources/webhook#execute-webhook" rel="nofollow noreferrer">https://discordapp.com/developers/docs/resources/webhook#execute-webhook</a></p>
  
  <p>Thank you for your time!</p>