rss & Flash
- Started
- Last post
- 4 Responses
- ericcampbell
I'm trying to pull in a Twitter and outforaride rss feed on a Flash site. It works fine locally, but when I host it the feed doesn't come through. I believe it's a security issue because I'm trying to pull XML content from another server. Anyone know anything about this or ways to fix the issue?
Thanks for the help.
- zaq0
look into crossdomain.xml
- acescence0
crossdomain requires that you have a policy file on the originating server, which won't work if you can't access that server to put it there. in that case you need to create a server-side proxy to read the data to your server, then feed it to flash
- noiseisthis0
yea. you cant get the feed directly due to twitter's cross domain policy.
http://twitter.com/crossdomain.x….you can use this php script and create a cron job to run the script to retrieve and write the file to your server.
<?php
//--- load in the xml ---
$theRAW = file_get_contents("http://twitter.com/statuses/user_timeline.xml?screen_name=<your user name here>");
$theXML = simplexml_load_string($theRAW);//--- load in xml file to edit. if doesnt exist, create ---
$xmlFile = "yourfilename.xml";
$xmlHandle = fopen($xmlFile, "w");//--- set xml as string to be written ---
$xmlString = $theXML->asXML();
echo($xmlString);//--- write xml to file ---
fwrite($xmlHandle, $xmlString);//--- close out xml file ---
fclose($xmlHandle);
?>and make the cron job run in intervals of 15min+. sometimes the php script will get the fail whale so create another cron job that uses the same script but name the xmlfile a diff file name. then in flash use a conditional:
if(xmlFile == "" || xmlFile == " ")
{
(use backup xmlFile)
}$5 thank you :)
- ericcampbell0
awesome. thanks noiseisthis.