Saludos.
Código:
y el archivo proxy.php es :<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="100%" creationComplete="init()"> <mx:Script> <![CDATA[ import mx.collections.ArrayCollection; import flash.net.navigateToURL; import mx.controls.Alert; import mx.rpc.events.ResultEvent; import mx.rpc.events.FaultEvent; [Bindable] private var proxyUrl:String; private function init():void { proxyUrl = Application.application.parameters.proxyUrl; } private var evedatos:ArrayCollection private function resultHandler(event:ResultEvent):void { evedatos = event.result.evec_api.quicklook.sell_orders.order; grilla.dataProvider = "evedatos"; } private function rssResults(e:ResultEvent):void { var rss:XML = new XML(e.result); rssOutput.text = rss.toXMLString(); } private function rssFault(e:FaultEvent):void { Alert.show(e.fault.rootCause.toString()); } ]]> </mx:Script> <mx:HTTPService id="proxyServic" method="POST" resultFormat="xml" url="proxy.php" result="rssResults(event)" fault="rssFault(event)"> <mx:request> <url>http://api.eve-central.com/api/quicklook?typeid=34</url> </mx:request> </mx:HTTPService> <mx:HTTPService id="proxyService" method="POST" resultFormat="xml" url="proxy.php" result="resultHandler(event)" fault="rssFault(event)"> <mx:request> <url>http://api.eve-central.com/api/quicklook?typeid=34</url> </mx:request> </mx:HTTPService> <mx:VBox width="100%" height="100%"> <mx:Button x="153" y="36" label="ProxyTextArea" width="160" click="{proxyService.send()}"/> <mx:Button x="153" y="36" label="ProxyDatagrid" width="160" click="{proxyServic.send()}"/> <mx:Panel x="0" y="0" width="100%" height="100%" layout="absolute" title="Cross Domain Proxy Demo"> <mx:VBox width="100%"> <mx:TextArea width="100%" height="300" editable="false" id="rssOutput" wordWrap="true"/> <mx:DataGrid width="100%" height="300" id="grilla" x="0" /> </mx:VBox> </mx:Panel> </mx:VBox> </mx:Application>
<?php
$ch = curl_init();
$timeout = 30;
$userAgent = $_SERVER['HTTP_USER_AGENT'];
curl_setopt($ch, CURLOPT_URL, $_REQUEST['url']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_USERAGENT, $userAgent);
$response = curl_exec($ch);
if (curl_errno($ch)) {
echo curl_error($ch);
} else {
curl_close($ch);
echo $response;
}
?>