如何去code AS3对象连接$ C $光盘AMF3在PHP [英] How to decode AS3 object encoded in AMF3 in PHP

查看:257
本文介绍了如何去code AS3对象连接$ C $光盘AMF3在PHP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图去code通过插座从Flash在PHP中发送的对象。 我尝试使用AMFPHP和ZEND_AMF但都没有奏效。

I am trying to decode an object sent through sockets from Flash in PHP. I tried using AMFPHP and ZEND_AMF but neither did worked.

有人点我到AMF3恩在PHP codeD对象进行解码的方式,而不使用AMFPHP远程功能? 数据被发送彻底的插座,所以我不能使用远程对象作为一般AMFPHP的作品。

Can someone point me to the way of decoding the AMF3 encoded objects in php without using remote functionality of the AMFPHP? Data is send thorough sockets, so I cannot use the remote objects as usually amfphp works.

推荐答案

@Ivan亚琴科感谢指向SabreAMF 下面是这样,我成功地去codeD和映射AMF3 EN codeD对象从的Flex / Flash的接收到插座

@Ivan Dyachenko Thanks for pointing towards SabreAMF Below is the way I successfully decoded and mapped the AMF3 encoded object received from Flex/Flash on sockets

include_once 'SabreAMF/AMF3/Serializer.php';
include_once 'SabreAMF/AMF3/Deserializer.php';
include_once 'SabreAMF/OutputStream.php';
include_once 'SabreAMF/InputStream.php';
include_once 'SabreAMF/TypedObject.php';
include_once 'SabreAMF/ClassMapper.php';

/************DECODER*****************/
SabreAMF_ClassMapper::registerClass('FLASH_CLASS_NAME','PHP_CLASS_NAME'); //CLASSES SHOULD BE SAME
$inputStream = new SabreAMF_InputStream($buffer);
$des = new SabreAMF_AMF3_Deserializer($inputStream);
$obj = $des->readAMFData();
//$obj will contain the instance of PHP_CLASS_NAME with the properties set as the values sent by Flex/Flash
/************END DECODER*****************/

/**************ENCODER******************/
$classObj = new PHP_CLASS(); //PHP_CLASS is your class
$object = new SabreAMF_TypedObject('FLASH_CLASS_NAME',$classObj); //FLASH_CLASS_NAME IS NAME OF CLASS AVAILABLE TO FLASH FOR MAPPING
$outputStream = new SabreAMF_OutputStream();
$serializer = new SabreAMF_AMF3_Serializer($outputStream);
$serializer->writeAMFData($object);
$output = $outputStream->getRawData();

//$output is AMF Encoded string to be sent to FLEX/FLASH. 
/***********END ENCODER***************/

这篇关于如何去code AS3对象连接$ C $光盘AMF3在PHP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆