I am using Dialogflow to create a chat interface. I have created a webhook from Dialogflow to XAMPP (specifically to http://localhost:8080
) to pass some data in json form from Dialogflow to a PHP script so as to process them.
However, my REQUEST METHOD $_SERVER['REQUEST_METHOD']
does not receive a POST REQUEST as it is specified in the form of Dialogflow but a GET REQUEST. In other words, in line $method = $_SERVER['REQUEST_METHOD'];
of my source code $method
is not 'POST'
as it was expected but 'GET'
.
From reading posts like the following:
- $_SERVER['REQUEST_METHOD'] return GET insted POST
- Using php and POST on a form, but request_method says it is a GET
- Php $_SERVER["REQUEST_METHOD"] alway return get
- https://github.com/postmanlabs/postman-app-support/issues/450
- https://teamtreehouse.com/community/why-doesnt-it-work-3
I have the impression that my problem arises because of a URL redirection and specifically because my webhook does not have the exact form that it should have as a URL. For example, if I use the URL http://localhost:8080/htdocs/index.php
where index.php
is my php script in XAMPP then I am redirected (not-automotically) to http://localhost:8080
. Specifically, what appears on my screen is the following:
Object not found!
The requested URL was not found on this server. If you entered the URL manually please check your spelling and try again.
If you think this is a server error, please contact the webmaster.
Error 404
localhost Apache/2.4.29 (Unix) OpenSSL/1.0.2n PHP/7.2.1 mod_perl/2.0.8-dev Perl/v5.16.3
The work 'localhost' has a hyperlink which redirects me to http://localhost:8080
if I press it.
Is URL redirection the problem?
If so, how can I deal with it so that I can receive finally my POST REQUEST?