Tag Archive for 'xml'

Overcome flash and RSS Crossdomain problems with AMFPHP and Magpie

The other day I was playing with the idea of getting RSS feeds with magpie and amfphp and here is the result of my testing. I would like to compare if my method is faster then just using URLLoader and parsing out xml in flash. Any one have any idea how I can test which is faster?

Any how on to the tests.
a few things you will need before you can get this to work.

Lets start out with taking a fast run through setting up our files.

  1. Go to http://amfphp.org and download the php frame work, extract it on your server. Inside of amfphp there is a folder named services
  2. The services folder is where I would like you to create a folder name “Rss_service” with out quotes.
  3. After you have made the folder go to and download magpie rss. Extract the magpie framework into the Rss_services folder **Note the current version of magpie is “magpierss-0.72″, if you are using a different version change the directory names in the code to correspond to your current version of magpie.**
  4. Make a PHP file called “RssHandler” with out quotes. heres our code for that file.
    items, $rss->channel);
    			return ($array);
    		}else{
    			return magpie_error();
    		}
    	}
    }
    ?>
    

    Do a test in the amfphp service browser to make sure you have no errors before moving on.

  5. If all is good with no errors go to and get the as3 remoting framework at http://osflash.org/as3lrf
  6. After you get the as3 framework up it will be time to make the flash file. Heres a example here of Action Script 3
    import com.dannypatterson.remoting.*;
    var serviceProxy:ServiceProxy;
    
    serviceProxy = new ServiceProxy("http://www.gfxcomplex.com/amfphp/gateway.php", "Rss_services.RssHandler");
    serviceProxy.addEventListener(ResultEvent.RESULT, onRes, false, 0, true);
    serviceProxy.getRss("http://rss.netflix.com/QueueRSS?id=P3743744853232005706625743118647423");
    
    function onRes(e:ResultEvent):void {
    	var array:Array = e.result as Array;
    	trace(array);
    }
    
  7. You will need a crossdomain.xml file on your own server to make this work. heres an example of what I use.
    
    
    
    
      
      
    
    

If all works as planed you will now have a great way to get around crossdomain problems with RSS and flash as seen here at http://gfxcomplex.com/labs/magpie_test.html. My example show a small list of movies from a rss feed at netflix which has no crossdomain.xml file making it a pain to work with in flash directly.

The big thing to note is that the xml is parsed out in php and sent back as an array so no client end parsing. I think its fast but I cant tell as I don’t know of a way to test this.