[FONT=Arial]Hi all,[/FONT]
[FONT=Arial]I’ve been having a nightmare trying to get an RSS feed work on a Flash site (Flash 8, AS2) I’m working on. The worst bit is… the deadline was yesterday! :s[/FONT]
[FONT=Arial]I’ve trawled google and various forums (including this one which has a few threads on this topic) and tried out lots of tutorials, scripts, samples and even bought one solution. None of them worked. The site in question (dev version at the moment) is: www.icstriplexgraduates.com/ics_9.html As you can see, the RSS feed should appear on the left. The feed itself is: http://www.controleng.com/CTL_general.xml[/FONT]
[FONT=Arial]It works fine when previewed from Flash, but fails on the server. I’ve done enough research to have determined this is because Flash can’t talk directly to a feed on another server. I tried various PHP proxy methods found on varous websites to parse the data, but again, none work.[/FONT]
[FONT=Arial]Yesterday I hit on the idea that it might be a server issue, and the hosts have apparently since set some permissions and allowed the feed URL through their firewall. Still no joy, though.[/FONT]
[FONT=Arial]If anyone could shed any light on the issue I’d be eternally grateful, the job is already overdue and I’m out of ideas; I only know basic AS and PHP and know next to nothing about servers. Are there server settings or security issues I need to be aware of? Is there anything wrong with my code? (see below)[/FONT]
[FONT=Arial]Many thanks in advance[/FONT]
[FONT=Arial]Flash code that calls the RSS (works in preview but not in browser):[/FONT]
function loadXML(loaded)
{ if (loaded) {
_root.name = this.firstChild.childNodes[0].childNodes[6].childNodes[0].firstChild.nodeValue;
_root.link = this.firstChild.childNodes[0].childNodes[6].childNodes[1].firstChild.nodeValue;
_root.name2 = this.firstChild.childNodes[0].childNodes[7].childNodes[0].firstChild.nodeValue;
_root.link2 = this.firstChild.childNodes[0].childNodes[6].childNodes[1].firstChild.nodeValue;
name_txt.text = _root.name;
comment_txt.text = _root.link;
name_txt2.text = _root.name2;
comment_txt2.text = _root.link2;
} else {
trace("file not loaded!");
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("http://www.controleng.com/CTL_general.xml");
[FONT=Arial]
Flash code calling feed via PHP parser is as above, except last line:[/FONT]
[FONT=Arial]
xmlData.load("www.icstriplexgraduates.com/proxy.php?url=http://www.controleng.com/CTL_general.xml");
[/FONT]
[FONT=Arial]PHP proxy file (doesn’t work):[/FONT]
[FONT=Arial]
<?php
header("Content-type: text/xml; charset=utf-8");
echo file_get_contents($_GET["dataURL"]);
?>
[/FONT]
[FONT=Arial]Alternative PHP proxy file (doesn’t work):[/FONT]
[FONT=Arial]
<?php
$post_data = $HTTP_RAW_POST_DATA;
$header[] = "Content-type: text/xml";
$header[] = "Content-length: ".strlen($post_data);
$ch = curl_init( $_GET['url'] );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
if ( strlen($post_data)>0 ){
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
}
$response = curl_exec($ch);
if (curl_errno($ch)) {
print curl_error($ch);
} else {
curl_close($ch);
print $response;
}
?>
[/FONT]