Categories
AS3 Flash

Twitter RSS reader – part 2

This is a “must-read” update for twitter rss reader in flash as3.


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?

  1. Ask Twitter to change there crossdomain.xml and add my domain…… (is this really an option?)
  2. 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.

Update #1: I found another proxy.php (I really don’t think you need another, but choices are nice 😀 ).
PHP Proxy Script for cross-domain requests
Sorry for the dutch error… I have a dutch version of XP (not my choice)

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()

2 replies on “Twitter RSS reader – part 2”

Comments are closed.