Topic: Including external for an rss feed...

Im having problems getting this to work.

Heres my feed:

http://www.sc2armory.com/forums/extern. … p;type=rss

Heres my php code:

<?php // FEED

define('PUN', 'SC2ARMORY.COM');
define('PUN_ROOT', $_SERVER["DOCUMENT_ROOT"] .'/forums/');
$type = (isset($_GET["type"])) ? $_GET["type"] : "";

switch ($type) {
    case "latest":
        include(PUN_ROOT .'extern.php?action=active&type=rss');
    break;
    
    case "new":
        include(PUN_ROOT .'extern.php?action=new&type=rss');
    break;
    
    case "news":
    default:
        include(PUN_ROOT .'extern.php?action=active&fid=1&type=rss');
    break;
}
?>

But it errors...

http://www.sc2armory.com/feed.php

Re: Including external for an rss feed...

Yeah, you're including extern.php on the local filesystem while still trying to pass URL parameters. That won't work wink
You need to include the full URL instead of a relative path

Re: Including external for an rss feed...

I tried:

include('http://www.sc2armory.com/forums/extern.php?action=active&type=rss');

And it still dont work.

Re: Including external for an rss feed...

What errors do you get then?

Re: Including external for an rss feed...

Parse error: syntax error, unexpected T_STRING in http://www.sc2armory.com/forums/extern. … p;type=rss on line 1

Re: Including external for an rss feed...

Aha, right, try
echo include('http://www.sc2armory.com/forums/extern.php?action=active&type=rss');

Or you could just use header("Location: whatever"); to redirect the request to the proper extern.php page

Re: Including external for an rss feed...

Includes didnt work, so I had to redirect.

Re: Including external for an rss feed...

<?php
class RSSParser {

    var $insideitem = false;
    var $tag = "";
    var $title = "";
    var $description = "";
    var $link = "";

    function startElement($parser, $tagName, $attrs) {
        if ($this->insideitem) {
            $this->tag = $tagName;
        } elseif ($tagName == "ITEM") {
            $this->insideitem = true;
        }
    }

    function endElement($parser, $tagName) {
        if ($tagName == "ITEM") {
            printf("<h1><a href='%s'>%s</a></b></dt></h1>",
                trim($this->link),htmlspecialchars(trim($this->title)));
            printf("<dd>%s</dd><br /><br />",htmlspecialchars(trim($this->description)));
            $this->title = "";
            $this->description = "";
            $this->link = "";
            $this->insideitem = false;
        }
    }

    function characterData($parser, $data) {
        if ($this->insideitem) {
        switch ($this->tag) {
            case "TITLE":
            $this->title .= $data;
            break;
            case "DESCRIPTION":
            $this->description .= $data;

            break;
            case "LINK":
            $this->link .= $data;
            break;
        }
        }
    }
}

$xml_parser = xml_parser_create();
$rss_parser = new RSSParser();
xml_set_object($xml_parser,&$rss_parser);
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen("RSS FEED GOES HERE","r")
    or die("Error reading RSS data.");
while ($data = fread($fp, 4096))
    xml_parse($xml_parser, $data, feof($fp))
        or die(sprintf("XML error: %s at line %d", 
            xml_error_string(xml_get_error_code($xml_parser)), 
            xml_get_current_line_number($xml_parser)));
fclose($fp);
xml_parser_free($xml_parser);


?>

Saw this in a tutorial a while back and coded it. This is from their source files though. If I can remember link I'll post it to give credit.

Re: Including external for an rss feed...

exatly same thing happened to me

MyFootballCafe.com  is Now Online!

Re: Including external for an rss feed...

The one I posted works really well.
Now, I know I'm not actually supposed to do this. Im just playing around and haven't showed this page to anyone. It does look the same as punbb homepage. I will take it down if you want me to.
The rss feed is pretty nice on here on the left hand column check it out.
http://thpsvids.com/users/gfg/home.php