1

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?

2
  • Works fine for me. Can you check if request is sent correctly (with Firebug or other preferred tool) Commented Jun 2, 2010 at 8:45
  • Uh, actually this is an AIR app! I traced the error result Commented Jun 2, 2010 at 9:11

1 Answer 1

2

This started working after I replaced

http://localhost:8888/api

with

http://localhost:8888/api/index.php

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.