Problem with HttpService POST
- by Lost_in_code
I'm trying to send some data to PHP using HTTPService POST but for some reason it's not working.
The same example works with GET but not with POST:
private function start():void{
var param:Object = {};
param.date = "2010-10-10";
userRequest.send(param);
userRequest.addEventListener(ResultEvent.RESULT, result);
userRequest.addEventListener(FaultEvent.FAULT, fault);
}
private function fault(e:FaultEvent):void{
trace(e.message);
}
private function result(e:ResultEvent):void{
trace(e.result);
}
<mx:HTTPService id="userRequest"
url="http://localhost:8888/api"
useProxy="false"
method="POST"/>
And here's the PHP code:
$d = $_POST['date'];
echo $d;
if($d == ""){
trace("Date not found!");
die();
}
This is the error I'm getting:
"Error #2032: Stream Error. URL:
http://localhost:8888/api"
But when I change the method in HTTPService to GET and in PHP I get the result as expected - PHP sends back the date:
2010-10-10
What am I doing wrong?