I am using PHP with XAMPP and Dialogflow to create a chat interface. In a simple intent(question) in Dialogflow, I have created a webhook to XAMPP regarding the question 'Who is X' (e.g. Paul, George). Therefore , I place a POST REQUEST in order to have access to the json form of this question in DIalogflow so that I can answer it as I want to. Specifically, the ultimate goal of this is to retrieve some data from a MySQL database in phpMyAdmin about this question and respond for example that 'X is a developer' or 'X is a financial analyst'. This is why wrote a php script which is the following:

```
<?php

$method = $_SERVER['REQUEST_METHOD'];

// Process when it is POST method
if ($method == 'POST') {
    $requestBody = file_get_contents('php://input');
    $json = json_decode($requestBody);

    $text = $json->result->parameters;

    switch($text) {
        case 'given-name':
            $name = $text->given-name;
            $speech = $name . 'is a developer';
            break;
        default:
            $speech = 'Sorry I did not get this. Can you repeat please?';
    }       

    $response = new \stdClass();
    $response->speech = "";
    $response->displayText = "";
    $respone->source = "webhook";
    echo json_encode($response);

}
else
{
    echo "Method not allowed";
}

?>

```

However, the output of this program is: `Method not allowed`.

Paradoxically enough `$method` has the value `'GET'` so it identifies a GET REQUEST while Dialogflow explicitly states at the webhook page that 

> 
> Your web service will receive a POST request from Dialogflow in the
>  form of the response to a user query matched by intents with webhook
>  enabled.
> 
> 
> 

Hence I am wondering: why my php script cannot see and process the POST REQUEST from Dialogflow?

P.S. Questions close to mine are the following: [Form sends GET instead of POST](https://stackoverflow.com/questions/37908024/form-sends-get-instead-of-post), [Why is $\_SERVER['REQUEST\_METHOD'] always GET?](https://stackoverflow.com/questions/26506168/why-is-serverrequest-method-always-get).