[SOLVED] PHP Get outgoing webhook

Hello there,

I am using Mattermost outgoing webhooks and trying to get the content of the POST requests.
The Content-Type is set to application/json and I am receiving a request each time someone post something in a public chat.
It is also possible to return an answer to a new request but I cannot read out the content of the POST.
Here is my php example:

<?php

header('Content-Type: application/json');

// Here I want to get the content of the message but I don't get it.
$message_content = $_POST['text'];

// This is the answer to my server and it works.
echo '{"text": "Successfully received your post."}';

?>

Hi @m-b,

Thanks for your feedback,

Is this documentation helpful?

Okay, in PHP you have to fetch the HTTP content with:
$json = file_get_contents('php://input');
Afterwards you convert the json to an array and …
$content = json_decode($json, true);

1 Like

Glad you’ve resolved your issue @m-b :slight_smile: