View Full Version : long and complex PHP/JS/AJAX/RSS question

03-02-2008, 01:04 AM
how do I create a script that serves RSS headlines hosted on my server that users can cut and paste simple code to embed in their blogs/sites that outputs those RSS headlines?

My Server: creates XML

User Site: user cuts and pastes code into his/her site, something simple like:

<script type="text/javascript" src="http://www.server.com/code.php"></script>

how can this be done?

03-02-2008, 01:16 AM
any help?

03-02-2008, 01:26 AM
no, I already know how to create an RSS feed.

that is step 1 and that is the easy part.

in fact, I will show you my basic example:

step 2 would be to create an AJAX .js file that parses the RSS feed and outputs it. here is step 2:


step 3 would be to cut and paste that above .js file into an external site... this is where I am stuck. I am doing this but nothing is happening. No errors. Nothing. View source the following link:


any help please?

03-02-2008, 11:38 AM
i think the problem here is that i would be trying to do an AJAX request across domains -- this is impossible to do.

so a proxy script must be setup.. but I am unsure how to do this.

can someone help?

03-13-2008, 06:30 AM
SimplePie Live! (http://live.simplepie.org) was designed exactly for this purpose... mostly. It is a web service that fetches and parses feeds on the server side using SimplePie, and it returns a JSON object that you can use in your pages. It'd be up to you to take the data and give it a display, but all-in-all, it takes care of it all.

On the pro side, SimplePie Live! uses JSONP (http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/) to bypass cross-domain issues (and is the same method that Google uses in most of their apps). This way, you can write simple JavaScript/DOM code and the feeds are fetched, parsed, cached, and converted to JSON on the server.

On the con side, although the JSON data that SimplePie Live! returns will work in essentially ANY JavaScript-enabled web browser, Internet Explorer seems to have issues with the script I wrote to load the external JSON file.

So, this solution will work with Firefox, Safari, and Opera, but I could definitely use some help in re-writing some of the JavaScript code for IE. ;)