zend amf read "php://input"
姬成荫
2023-12-01
// Include the Zend Loader
require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
$loader->setFallbackAutoloader(true);
$loader->suppressNotFoundWarnings(false);
// Create an instance of Amf Server
$server = new Zend_Amf_Server();
// Map PHP Class to Flash Class
$server->setClassMap('InventoryObject', 'InventoryObject');
$server->setClassMap('CManagedObjectReference', 'CManagedObjectReference');
/* GET DATA FROM FLEX CLIENT */
[color=red]$amf = file_get_contents('php://input');[/color]
// Remove first byte (new line)
$amf = substr($amf, 1);
// Create a Parser
$stream = new Zend_Amf_Parse_InputStream($amf);
// Deseriaize string into AMF3
$d = new Zend_Amf_Parse_Amf3_Deserializer($stream);
// Read as native PHP object
$data = $d->readObject();
// Serialize the object into binary format
$serializedObj = serialize($data->obj);