MP3 site Music shop Billy Talent Carcass Bjork Pitbull MP3 search Ozzy Osbourne Music database Steve Perry Pink Floyd

Twitter in Flash – Getting Past the SecurityErrorEvent

woven-interactive-twitter

We took on a small task today to add our latest Tweet’s to the homepage of our site. We decided to go with the library twitterscript. It’s a nice simple wrapper around the twitter API and allows you to quickly create your app. All this with one catch. Out of the box it only works locally due to twitters cross domain policy.

To get around this we had to make a few tweaks to the code and add a proxy file.

Twitter.as – Changed lines 55 – 98
[as]
private static const LOAD_FRIENDS_URL:String =
“/proxy.php?path=statuses/friends/$userId.xml”;
private static const LOAD_FRIENDS_TIMELINE_URL:String =
“/proxy.php?path=statuses/friends_timeline/$userId.xml”;
private static const PUBLIC_TIMELINE_URL:String =
“/proxy.php?path=statuses/public_timeline.xml”
private static const LOAD_USER_TIMELINE_URL:String =
“/proxy.php?path=statuses/user_timeline/$userId.xml”
private static const FOLLOW_USER_URL:String =
“/proxy.php?path=friendships/create/$userId.xml”;
private static const SET_STATUS_URL:String =
“/proxy.php?path=statuses/update.xml”;
private static const SHOW_STATUS_URL:String =
“/proxy.php?path=statuses/show/$id.xml”;
private static const REPLIES_URL:String =
“/proxy.php?path=statuses/replies.xml”;
private static const DESTROY_URL:String =
“/proxy.php?path=statuses/destroy/$id.xml”;
private static const FOLLOWERS_URL:String =
“/proxy.php?path=statuses/followers.xml”;
private static const FEATURED_USERS_URL:String =
“/proxy.php?path=statuses/featured.xml”;
private static const GET_DIRECT_MSGS_URL:String =
“/proxy.php?path=direct_messages.xml?”;
private static const SEND_DIRECT_MSG_URL:String =
“/proxy.php?path=direct_messages/new.xml”;
private static const SEARCH_URL:String =
“/proxy.php?sd=search&path=search.atom?”;
private static const VERIFY_URL:String =
“/proxy.php?path=account/verify_credentials.xml”;
private static const UPDATE_LOCATON_URL:String =
“/proxy.php?path=account/update_location”;
private static const RATE_LIMIT_STATUS_URL:String =
“/proxy.php?path=account/rate_limit_status.xml”;
private static const END_SESSION_URL:String =
“/proxy.php?path=account/end_session.xml”;
private static const GET_SENT_DIRECT_MESSAGE_URL:String =
“/proxy.php?path=direct_messages/sent.xml”;
private static const SHOW_INFO_URL:String =
“/proxy.php?path=users/show/${id}.xml”;
private static const FRIENDS_IDS_URL:String =
“/proxy.php?path=friends/ids/${id}.xml”;
private static const FOLLOWERS_IDS_URL:String =
“/proxy.php?path=followers/ids/${id}.xml”;
[/as]

Then adding a proxy.php file to our server:

[as][/as]

Do this and you’ll be rid of the Security Errors and able to integrate Twitter into your Flash site.

If you or your clients need any help, feel free to contact our interactive agency.


9 responses so far, want to say something?

  1. Trevor Boyle says:

    Thanks for this, it saved me some thought and time.

    I was having an issue with caching so also added a Cache-Control to the header.

    Here’s the result (which I will be developing further when I get a chance)…
    http://blog.trevorboyle.com/wp-content/uploads/twittersphere/Twittersphere-Visualizer.html

    Thanks,
    Trevor

  2. Small Twitter app in Adobe AIR - ceeya blog says:

    […] box it only works locally due to twitters cross domain policy. Approximately the same as explained here, only I used a custom endpoint with the use of curl, because it is cool and I needed some extra […]

  3. Oops… I think I just blogged » Blog Archive » Through the Twittersphere says:

    […] library (http://code.google.com/p/twitterscript/) and a php proxy script by Woven Interactive (http://woveninteractive.net/?p=45) I have created a simple flash visualisation of Twitter’s […]

  4. Creating a Twitter Widget Using Flex and TwitterScript | The Blog of Jon Karna says:

    […] and Flash (twitterscript).  After creation of my widget, I had to reference this article, Twitter in Flash – Getting Past the SecurityErrorEvent, to troubleshoot twitter’s cross domain policy. Posted in Uncategorized | Tagged […]

  5. Twitter Widget using Flex 3 Revisited | The Blog of Jon Karna says:

    […] Twitter and Flash (twitterscript).  After creation of my widget, I had to reference this article, Twitter in Flash – Getting Past the SecurityErrorEvent, to troubleshoot twitter’s cross domain […]

  6. FOTB09 -flash + audio +as3 at ting says:

    […] http://woveninteractive.net/2009/02/twitter-in-flash-getting-past-the-securityerrorevent/ « as3 […]

  7. miguelMoraleda says:

    Thanks that is very useful, but I steel have problems trying to send a new tweet. After insert I get success, but never insert the message in twitter. It was working fine in local but not in the server. Im only using the search and setstatus command. In the server never works. After to install your proxy system the search works fine, but the inserting not. Any idea ?

  8. Twitter RSS reader – part 2 | [mck] says:

    […] 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 […]

  9. Paul says:

    Thanks for this, cured a very painful headache for me.

    I hate the security errors in Flash.

Leave a Reply