Flex:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute"
     creationComplete="onCreationComplete()">
     <mx:Script>
         <![CDATA[
             private function onCreationComplete():void
             {
                 var POSTParameters:Object = new Object();
                 POSTParameters["-1"] = "A";
                 POSTParameters["0"] = "B";
                 POSTParameters["1"] = "C";
                 doPOST.send(POSTParameters);
             }
         ]]>
     </mx:Script>
     <mx:HTTPService id="doPOST"
url="http://action.gcsc.att.com/v2dev/test2.php";
         useProxy="false" method="POST"/>
</mx:Application>

PHP:
<?php
$handle = fopen("/var/www/html/debug.txt", 'w');
$data = print_r($_POST, true);
fwrite($handle, $data . "\n");
fclose($handle);
?>

Check the debug.txt file. It should look like:
Array
(
     [-1] => A
     [0] => B
     [1] => C
)

Note: This is also shown in Charles (http://www.charlesproxy.com)



HTH




Steve


--- In [email protected], "kenny14390" <kenny14...@...> wrote:
>
> Hi,
>
> We all know about PHP's ability to send an array through the $_POST
> variable, in a form for example:
>
> [form method="POST" action=""]
> [text type="input" name="data[name]"/]
> ...
> [/form]
>
> But how can I achieve that through Flex's HTTPService?
>
> If I were to print_r($_POST) in the PHP page, this is would I would
like
> to see:
>
>
> Array
> (
>      [data] => Array
>          (
>              [-1] => A
>              [0] => B
>              [1] => C
>          )
>
> )
>
> I have tried this programmatically while calling the
send(params:Object)
> method of the HTTPService, with the Object containing {data:
> {'-1':'A','0':'B','1':'C'}} but the result is more like [data] =>
> [object Object]
>
>
> Any ideas how to mimic PHP's ability to POST an array?
>
>
> Note: I can achieve this easily with GET, by appending
> "data[-1]=A&data[0]=B&data[1]=C" to the URL, but my problem requires
> POST.
>
>
>
> Thanks.
>

Reply via email to