Search code examples
codeigniterwebhooksmailgunpayload

Mailgun webhook incoming payload is empty


I try to get payload from mailgun webhook in Codeignaiter but all these are empty.

function index($payload = '')
{
        var_dump($_POST); // empty
        var_dump($_GET); // empty
        var_dump($payload); // empty
}

I test my webhook url from mailgun dashboard , it is ok and it works but with empty payload.

Response: array(0) {
}
array(0) {
}
string(0) ""

But when test with Postbin it returns data like this

{
  "timestamp": "1602575614",
  "token": "3d21344bf13e4999bc6233a2031984f5ed4a7d9b5a42df9189",
  "signature": "b1269faef2b44ce7f1ceaada83838691ed00203d1eb228e9c7097b7ec725a19c"
}
...

What can be a reason of empty data ?


Solution

  • This one will return data I need

    $postedData = json_decode(file_get_contents('php://input'), TRUE);
    print_r($postedData);