/** * __construct * * @return void */ public function __construct() { $data = $this->readInput(); //file_put_contents($dump.'/' . md5($data),$data); $this->amfInputStream = new SabreAMF_InputStream($data); $this->amfRequest = new SabreAMF_Message(); $this->amfOutputStream = new SabreAMF_OutputStream(); $this->amfResponse = new SabreAMF_Message(); $this->amfRequest->deserialize($this->amfInputStream); }
function brightcove_decode($string) { $stream = new SabreAMF_InputStream($string); $message = new SabreAMF_Message(); $message->deserialize($stream); $t = $message->getBodies(); return $t[0]; }
/** * Real AMF functioning simulation * * @param <type> $method_return * @return <type> */ protected function _makeAmfResponseFromMethodReturn($method_return) { $response = new SabreAMF_AMF3_AcknowledgeMessage(); $response->body = $method_return; $amfResponse = new SabreAMF_Message(); $amfResponse->addBody(array('target' => '/onResult', 'response' => '', 'data' => $response)); $amfOutputStream = new SabreAMF_OutputStream(); $amfResponse->serialize($amfOutputStream); $amfInputStream = new SabreAMF_InputStream($amfOutputStream->getRawData()); $amfResponse2 = new SabreAMF_Message(); $amfResponse2->deserialize($amfInputStream); $bodies = $amfResponse2->getBodies(); //var_dump($bodies); return $bodies[0]['data']->body; }
/** * sendRequest * * sendRequest sends the request to the server. It expects the servicepath and methodname, and the parameters of the methodcall * * @param string $servicePath The servicepath (e.g.: myservice.mymethod) * @param array $data The parameters you want to send * @return mixed */ public function sendRequest($servicePath, $data) { // We're using the FLEX Messaging framework if ($this->encoding & SabreAMF_Const::FLEXMSG) { // Setting up the message $message = new SabreAMF_AMF3_RemotingMessage(); $message->body = $data; // We need to split serviceName.methodName into separate variables $service = explode('.', $servicePath); $method = array_pop($service); $service = implode('.', $service); $message->operation = $method; $message->source = $service; $data = $message; } $this->amfRequest->addBody(array('target' => $this->encoding & SabreAMF_Const::FLEXMSG ? 'null' : $servicePath, 'response' => '/1', 'data' => $data)); $this->amfRequest->serialize($this->amfOutputStream); // The curl request $ch = curl_init($this->endPoint); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 20); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: ' . SabreAMF_Const::MIMETYPE)); curl_setopt($ch, CURLOPT_POSTFIELDS, $this->amfOutputStream->getRawData()); if ($this->httpProxy) { curl_setopt($ch, CURLOPT_PROXY, $this->httpProxy); } $result = curl_exec($ch); if (curl_errno($ch)) { throw new Exception('CURL error: ' . curl_error($ch)); false; } else { curl_close($ch); } $this->amfInputStream = new SabreAMF_InputStream($result); $this->amfResponse = new SabreAMF_Message(); $this->amfResponse->deserialize($this->amfInputStream); $this->parseHeaders(); foreach ($this->amfResponse->getBodies() as $body) { if (strpos($body['target'], '/1') === 0) { return $body['data']; } } }
/** * sendRequest * * sendRequest sends the request to the server. It expects the servicepath and methodname, and the parameters of the methodcall * * @param string $servicePath The servicepath (e.g.: myservice.mymethod) * @param array $data The parameters you want to send * @return mixed */ public function sendRequest($servicePath, $data) { // We're using the FLEX Messaging framework if ($this->encoding & SabreAMF_Const::FLEXMSG) { // Setting up the message $message = new SabreAMF_AMF3_RemotingMessage(); $message->body = $data; // We need to split serviceName.methodName into separate variables $service = explode('.', $servicePath); $method = array_pop($service); $service = implode('.', $service); $message->operation = $method; $message->source = $service; $data = $message; } $this->amfRequest->addBody(array('target' => $this->encoding & SabreAMF_Const::FLEXMSG ? 'null' : $servicePath, 'response' => '/1', 'data' => $data)); $this->amfRequest->serialize($this->amfOutputStream); ##test /* require '../Zebra_cURL.php'; $curl = new Zebra_cURL($this->endPoint); $curl->cache('cache', 3600); $curl->threads = 10; $curl->option(array( CURLOPT_CURLOPT_POST => 1, CURLOPT_FOLLOWLOCATION => TRUE, CURLOPT_REFERER => 'http://www.trilulilu.ro', CURLOPT_TIMEOUT => 20, CURLOPT_HTTPHEADER => array('Content-type: ' . SabreAMF_Const::MIMETYPE), CURLOPT_USERAGENT => 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13', CURLOPT_RETURNTRANSFER => 1, CURLOPT_POSTFIELDS => $this->amfOutputStream->getRawData(), )); $v=$curl->get($url); $data=$v->body; $result = html_entity_decode($data); ## */ // The curl request $ch = curl_init($this->endPoint); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_REFERER, 'http://www.trilulilu.ro'); curl_setopt($ch, CURLOPT_TIMEOUT, 20); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: ' . SabreAMF_Const::MIMETYPE)); curl_setopt($ch, CURLOPT_POSTFIELDS, $this->amfOutputStream->getRawData()); if ($this->httpProxy) { curl_setopt($ch, CURLOPT_PROXY, $this->httpProxy); } $result = curl_exec($ch); if (curl_errno($ch)) { throw new Exception('CURL error: ' . curl_error($ch)); false; } else { curl_close($ch); } $this->amfInputStream = new SabreAMF_InputStream($result); $this->amfResponse = new SabreAMF_Message(); $this->amfResponse->deserialize($this->amfInputStream); $this->parseHeaders(); foreach ($this->amfResponse->getBodies() as $body) { if (strpos($body['target'], '/1') === 0) { return $body['data']; } } }