Sideas
asked on
XML feed from Twitter
Hi, this works on my desktop but not online: I call Main() at any point on the tmeline so I thought it would have enough time to parse the xml...and if not how do I???
Cheers
Cheers
var twitterXML:XML; // This holds the xml data
function Main()
{
var myTwitterID:Number = 19526069;
// Fire the loadTwitterXML method, passing it the url to your Twitter info:
loadTwitterXML("http://twitter.com/statuses/user_timeline/19526069.xml");
function loadTwitterXML(URL:String):void
{
var urlLoader:URLLoader = new URLLoader();
// When all the junk has been pulled in from the url, we'll fire finishedLoadingXML:
urlLoader.addEventListener(Event.COMPLETE, finishLoadingXML);
urlLoader.load(new URLRequest(URL));
}
function finishLoadingXML(e:Event = null):void
{
// All the junk has been pulled in from the xml! Hooray!
// Remove the eventListener as a bit of housecleaning:
e.target.removeEventListener(Event.COMPLETE, finishLoadingXML);
trace("LOADED");
// Populate the xml object with the xml data:
twitterXML = new XML(e.target.data);
showTwitterStatus();
}
function showTwitterStatus():void
{
trace(twitterXML);
// Prep the text field to hold our latest Twitter update:
twitter_txt.wordWrap = true;
twitter_txt.autoSize = TextFieldAutoSize.LEFT;
// Populate the text field with the first element in the status.text nodes:
twitter_txt.htmlText = twitterXML.status.text[0];
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can view the crossdomain.xml file here if your interested: http://www.twitter.com/crossdomain.xml
You can get around this by creating your own proxy using server side code (PHP, ColdFusion etc) to retrieve the XML and supply it to you. That circumvents the whole crossdomain business.
the call looks something like this:
http://mydomain.com/proxy.cfm?url=http://yourdomain.com/file.xml
the call looks something like this:
http://mydomain.com/proxy.cfm?url=http://yourdomain.com/file.xml