Very short tricks like proxy RSS with SimplePie

If you use Flash or Ajax to read RSS feeds from other domains, you need to equip yourself with a proxy (tunneling) because of the protections imposed by both technologies (see tunneling and proxy server for Ajax and not only ). If your site or blog is already SimplePie , you can write a simple proxy in this way:

1
2
3
4
5
6
; require_once "simplepie.inc";

new SimplePie ( ) ; $ Feed = new SimplePie ();
set_feed_url ( 'http://www.undolog.com/feed' ) ; $ Feed -> set_feed_url ('http://www.undolog.com/feed');
enable_xml_dump ( true ) ; $ Feed -> enable_xml_dump (true);
init ( ) ; $ Feed -> init ();

In this file (such as proxy.php) you can send GET the url of the feed you want to read:

1
2
3
4
5
6
; require_once "simplepie.inc";

new SimplePie ( ) ; $ Feed = new SimplePie ();
set_feed_url ( $_GET [ 'feedurl' ] ) ; $ Feed -> set_feed_url ($ _GET ['feedUrl']);
enable_xml_dump ( true ) ; $ Feed -> enable_xml_dump (true);
init ( ) ; $ Feed -> init ();

Using the call proxy.php?feedurl=http://www.cnn.com/feed