I'm new in webservice and I created a little example.
The code is:
$json_encoded = file_get_contents('php://input');
$array = json_decode($json_encoded, true);
if ( count($array) ) {
echo "OK: data received";
} else {
echo "NO data received";
}
This little script is located at http://www.example.com/api/check/index.php
Now if I try to use POSTMAN software to test it wth a json payload, it works great if I use a POST call at http://www.example.com/api/check/ :
OK: data received
But if I try to send a request to the same address without trailing slash http://www.example.com/api/check i get:
NO data received
Is there a way to get it working for both calls (with and without trailing slash) ?
I cannot edit server config, so i'd like to get it working editing index.php or adding an .htaccess here http://www.example.com/api/check/
Any suggest?