Decode amf3 object using PHP
Posted
by Xuki
on Stack Overflow
See other posts from Stack Overflow
or by Xuki
Published on 2010-04-13T09:21:31Z
Indexed on
2010/04/13
9:23 UTC
Read the original article
Hit count: 388
My flash code:
var request=new URLRequest('http://localhost/test.php');
request.method = URLRequestMethod.POST;
var data = new URLVariables();
var bytes:ByteArray = new ByteArray();
bytes.objectEncoding = ObjectEncoding.AMF3;
//write an object into the bytearray
bytes.writeObject(
{ myString:"Hello World"}
);
data.data = bytes;
request.data = data;
var urlLoader:URLLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
urlLoader.addEventListener(Event.COMPLETE, onCompleteHandler);
urlLoader.load(request);
function onCompleteHandler(evt:Event):void {
trace(evt.target.data);
}
PHP code:
define("AMF_AMF3",1);
$data = $_POST['data'];
echo amf_decode($data, AMF_AMF3);
Basically I need to send an AMF3 object from Flash to PHP and unserialize it. I'm using AMFEXT extension but couldn't get it to work. Any idea?
© Stack Overflow or respective owner