Getting RSS (or a XML) from a server without a crossdomain.xml

By | December 18, 2007

I just added a new feature to my blog, it display my RSS feed from StumbleUpon. Everything worked well as long as I did not upload it to my server. Once uploaded I got an error coming from StumbleUpon. It appears that they don’t host a crossdomain.xml (or I did not found it)…

The only way I found to still be able to get my RSS working was to do a small server side script (with php) that get the content of the page and then display it.

PHP:

$theUrl = $_POST['theURL'];
$content = file_get_contents($theUrl);
echo $content;

In Flash you just have to make an URLRequest:
AS3:

var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onXmlComplete);
var request:URLRequest = new URLRequest("http://[yourserver.com]/getanyRSS.php");
var variables:URLVariables = new URLVariables();
variables.theURL = "theURL2Extract";
request.data = variables;
request.method = URLRequestMethod.POST;
loader.load(request);
function onXmlComplete(e:Event):void
{
//handle your RSS - XML
}

And voila!
Now the question is why the security sandbox is interfering with accessible content from Internet? Flash and AJAX technologies both have this issue and really it does not make sense IMHO in most of the case. I would prefer if all external content was accessible until we deny the access.

Ahmet

 
0 Kudos
Don't
move!

2 thoughts on “Getting RSS (or a XML) from a server without a crossdomain.xml

Thoughts?