I was having some problems with a flash file that requires an external xml file so it can render random data…
Everything was working fine, except when it was in a cake app… long story short,
I found this post about PHP Proxy Script for cross-domain requests which had everything I needed.
Just put the proxy.php like this in your server:
http://yourserver.com/proxy.php
<?php
// PHP Proxy
// Responds to both HTTP GET and POST requests
//
// Author: Abdul Qabiz
// March 31st, 2006
//
// Get the url of to be proxied
// Is it a POST or a GET?
$url = ($_POST['url']) ? $_POST['url'] : $_GET['url'];
$headers = ($_POST['headers']) ? $_POST['headers'] : $_GET['headers'];
$mimeType =($_POST['mimeType']) ? $_POST['mimeType'] : $_GET['mimeType'];
//Start the Curl session
$session = curl_init($url);
// If it's a POST, put the POST data in the body
if ($_POST['url']) {
$postvars = '';
while ($element = current($_POST)) {
$postvars .= key($_POST).'='.$element.'&amp;amp;amp;amp;amp;amp;amp;amp;amp;';
next($_POST);
}
curl_setopt ($session, CURLOPT_POST, true);
curl_setopt ($session, CURLOPT_POSTFIELDS, $postvars);
}
// Don't return HTTP headers. Do return the contents of the call
curl_setopt($session, CURLOPT_HEADER, ($headers == "true") ? true : false);
curl_setopt($session, CURLOPT_FOLLOWLOCATION, true);
//curl_setopt($ch, CURLOPT_TIMEOUT, 4);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
// Make the call
$response = curl_exec($session);
if ($mimeType != "")
{
// The web service returns XML. Set the Content-Type appropriately
header("Content-Type: ".$mimeType);
}
echo $response;
curl_close($session);
?>
Go to your action script file and modify your content_xml.load:
content_xml.load("http://www.yourserver.com/xml/menu.xml");
Finally, in your cake app:
<!--Valid flash version 8.0-->
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="your width" height="your height" id="your id" accesskey="your accesskey" tabindex="your tabindex" title="your title">
<param name="movie" value="http://yourserver.com/proxy.php?url=http%3A//someserver.com/swf.swf&amp;amp;amp;amp;amp;amp;amp;amp;amp;mimeType=application/x-shockwave-flash" />
<param name="quality" value="your value" />
<param name="wmode" value="your value" />
<param name="swfversion" value="6.0.65.0" />
<!-- This param tag prompts users with Flash Player 6.0 r65 and higher to download the latest version of Flash Player. Delete it if you don’t want users to see the prompt. -->
<param name="expressinstall" value="/Scripts/expressInstall.swf" />
<param name="SCALE" value="your value" />
<param name="allowScriptAccess" value="your value" />
<param name="base" value="http://yourserver.com/" />
<param name="allowNetworking" value="all" />
<!-- Next object tag is for non-IE browsers. So hide it from IE using IECC. -->
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="http://yourserver.com/proxy.php?url=http%3A//someserver.com/swf.swf&amp;amp;amp;amp;amp;amp;amp;amp;amp;mimeType=application/x-shockwave-flash" width="980" height="325">
<!--<![endif]-->
<param name="quality" value="your value" />
<param name="wmode" value="your value" />
<param name="swfversion" value="6.0.65.0" />
<param name="expressinstall" value="/Scripts/expressInstall.swf" />
<param name="SCALE" value="your value" />
<param name="allowScriptAccess" value="always" />
<param name="base" value="http://yourserver.com/" />
<param name="allowNetworking" value="all" />
<!-- The browser displays the following alternative content for users with Flash Player 6.0 and older. -->
<div>
<h4>Content on this page requires a newer version of Adobe Flash Player.</h4>
<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" width="112" height="33" /></a></p>
</div>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
0 Responses
Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.