I have implemented a web service in PHP. This service takes name/value pairs as input and returns JSON encoded strings.
Everything was working as expected on my local apache web servers running on mac-osx and windows 7. However, after hosting my PHP scripts on this linux based web service provider, my POST requests to the service are failing.
By backend PHP script which fails is as follows:
if (session_id() == "") {
session_start();
}
ob_start();
$command = isset($_REQUEST["Command"]) ? $_REQUEST["Command"] : "";
if ($command == "") {
echo("Handler Not Found: ");
print_r($_REQUEST);
}
The output from a POST request to the url with Command=do_foo is always Handler Not Found:. It is as if the web service never receives any of the parameters I send. The value of $_REQUEST is printed as:
[PHPSESSID] => db0af76fe8028e70dc96f816d0dbe927
If I change the invocation method to GET everything works as expected. What am I missing?
PS: I’m calling this web service in an Android app using apache.http.client.methods.HttpGet and `apache.http.client.methods.HttpGet. I have verified that the POST fails even if I send the POST request through the FireFox add-on Poster
EDIT:
-
I have the same problem if I use the
$_POSTsuper global. -
I cannot ssh into my hosting server, but CPANEL is showing me that
register_globals=off. I don’t know if that can create problems.
Have a look at the ini setting variables-order or request-order. Maybe POST variables are disabled to be included in the
$_REQUESTsuper-global.