read here the complete (dutch) error message
Stupid, stupid, stupid, I already knew this: Flash cross-domain security.
Which simple says that it’s not allowed to “get” anything from another website unless the server has a crossdomain.xml
.
The nasty part is that, while you are testing in Flash IDE nothing goes wrong. So I only bumped into this when I put it on my server…
So what to do?
- Ask Twitter to change there
crossdomain.xml
and add my domain…… (is this really an option?) - Find something around the crossdomain security from Flash
Luckily solution two is the easiest one: use a proxy to get the data we want.
Because PHP doesn’t have the same restrictions as Flash has we will be using a proxy.php.
This is how it works: Flash wants a crossdomain.xml
if you “get” data from another server, but if you “get” data from the same server there is no problem. So we will be asking the proxy.php
to “get” the xml/rss and serve it to Flash.
So instead of loading the data directly from Twitter
http://twitter.com/statuses/user_timeline/27657030.rss
We will be using the proxy instead
http://yoursite.com/xml_proxy.php?url=http://twitter.com/statuses/user_timeline/27657030.rss
I didn’t write the proxy myself:
The proxy that I used can be found here: http://xmlrpcflash.mattism.com/proxy_info.php (it has some extra explanation about the subject )
This proxy can be use for all sorts of xml, and any server.
As always I’m reinventing the wheel: this group needed a specific solution but is nice to read more about it:
http://woveninteractive.net/2009/02/twitter-in-flash-getting-past-the-securityerrorevent/
They wrote something similar, but a proxy more specific suited for twitter and the use of twitterscript.
PHP Proxy Script for cross-domain requests
Error #2044: Niet-afgehandelde securityError:. text=Error #2048: Schending van beveiligingssandbox: http://emceekay.nl/paper/flash/twttr.swf kan geen gegevens laden van http://twitter.com/statuses/user_timeline/27657030.rss.
at nl.emceekay.twttr::TwttrBase/getFeed()
at nl.emceekay.twttr::TwttrMain()