如何解码在PHP中AMF3编码的AS3对象(How to decode AS3 object enc

2019-07-31 16:08发布

我试图通过解码插座从Flash在PHP中发送的对象。 我尝试使用AMFPHP和ZEND_AMF但也没有工作。

有人能指出我在PHP AMF3编码的对象进行解码的方式,而不使用AMFPHP的遥控功能? 数据被发送彻底插座,从而通常AMFPHP作品我不能使用远程对象。

Answer 1:

@Ivan亚琴科感谢朝SabreAMF指着下面是我成功解码的方式,映射AMF3从的Flex / Flash的接受了插座的编码对象

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***************/


Answer 2:

您可以使用SabreAMF编码/ PHP的解码AMF数据。



Answer 3:

请看看这个- https://github.com/neoxic/php-amf3 -这是一个非常可靠的PHP扩展编码/解码AMF3流。



文章来源: How to decode AS3 object encoded in AMF3 in PHP