Browse Source

Explicitly set content-type header, and post JSON as body

Harm Bandstra 8 năm trước cách đây
mục cha
commit
52d9096b14
1 tập tin đã thay đổi với 2 bổ sung1 xóa
  1. 2 1
      src/Monolog/Handler/SlackWebhookHandler.php

+ 2 - 1
src/Monolog/Handler/SlackWebhookHandler.php

@@ -87,7 +87,8 @@ class SlackWebhookHandler extends AbstractProcessingHandler
         if (defined('CURLOPT_SAFE_UPLOAD')) {
             curl_setopt($ch, CURLOPT_SAFE_UPLOAD, true);
         }
-        curl_setopt($ch, CURLOPT_POSTFIELDS, array('payload' => $postString));
+        curl_setopt($ch, CURLOPT_HTTPHEADER, ['Content-type: application/json']);
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
 
         Curl\Util::execute($ch);
     }