RSS feed creation for whole Phorum

Posted by Brian Moon 
Re: RSS feed creation for whole Phorum
November 16, 2004 02:46PM
This is for those of you who use e.g. Magpie and want to pars something in compliance with W3C

require_once('rss_fetch.inc');
error_reporting(E_ERROR);
define('MAGPIE_CACHE_ON', 1);
define('MAGPIE_CACHE_DIR', 'cache');
define('MAGPIE_CONDITIONAL_GET_ON', 1);
define('MAGPIE_CACHE_AGE', 10800);



$url = '[www.b92.net];;
$max_items = 5;
$rss = fetch_rss($url);
$items = array_slice($rss->items, 0, $max_items);

foreach ($items as $item) {
$title = $item[title];
$href = $item[link];
$url = htmlentities($item[link]);


echo "<a href=\"".htmlentities($url)."\" target=\"_blank\">* $title</a><br>\n";


}
echo "<p>", $rss->channel['title'], "</p>";
?>

Sergej

------------------------------------------
^AU^ Assassins United
[www.assassinsunited.com]
------------------------------------------
Re: RSS feed creation for whole Phorum
November 17, 2004 11:57AM
this is the 'modified' version of rss.php (with an other file : logorss.php) we use on lea-linux.org :

- it can add some "image" to a channel
- it set the charset (both in <?xml> tag, and in the type/mime)
- it validate the feed with [feedvalidator.org] (using dummy email in the feed, right charset setting, fixe wrong language setting : fr_FR -> fr-FR as expected by feedvalidator)

hope it can help



Edited 1 time(s). Last edit at 11/17/2004 11:58AM by leafred.
Attachments:
open | download - phorss.zip (2.4 KB)
Re: RSS feed creation for whole Phorum
December 04, 2004 04:27AM
Hi,

still have a warning if a user not logged in:


[spec-f.de]

warning for rss.php:
Warning: Invalid argument supplied for foreach() in /var/www/web7/html/phorum/rss.php on line 46

warning for phorss.php
Warning: Invalid argument supplied for foreach() in /var/www/web7/html/phorum/rss.php on line 51

I'm to stupid to fix it for myself. Need you help, please.


Regards, Stoebi
Re: RSS feed creation for whole Phorum
December 06, 2004 10:41AM
Good... in my example creates problem.

[edizioni.iwa-italy.org]

Btw, remember the Alt text in the sample ;-)
mt
Re: RSS feed creation for whole Phorum
December 06, 2004 10:44AM
Stoebi Wrote:
-------------------------------------------------------

> warning for rss.php:
> Warning: Invalid argument supplied for foreach()
> in /var/www/web7/html/phorum/rss.php on line 46
>
> warning for phorss.php
> Warning: Invalid argument supplied for foreach()
> in /var/www/web7/html/phorum/rss.php on line 51

Do you have this error also, if you are logged in? Can you create an open Forum for tests?




rscano Wrote:
-------------------------------------------------------
> Good... in my example creates problem.
>

Hmmm, what kind of problems? If I look on the following Feeds, it looks not bad
[edizioni.iwa-italy.org]
[edizioni.iwa-italy.org]
[edizioni.iwa-italy.org]


regards
mt



Edited 1 time(s). Last edit at 12/06/2004 10:46AM by mt.
Re: RSS feed creation for whole Phorum
December 07, 2004 02:05AM
mt Wrote:
-------------------------------------------------------
> Stoebi Wrote:
> --------------------------------------------------
> -----
>
> > warning for rss.php:
> > Warning: Invalid argument supplied for
> foreach()
> > in /var/www/web7/html/phorum/rss.php on line
> 46
> >
> > warning for phorss.php
> > Warning: Invalid argument supplied for
> foreach()
> > in /var/www/web7/html/phorum/rss.php on line
> 51
>
> Do you have this error also, if you are logged in?
> Can you create an open Forum for tests?

No, if i logged in, no error. Warning appears only, if a user not logged in.

If a new user visited my site and looks and clicks around, it makes not a good impression if a site
shows warning, errors etc.

[spec-f.de]

and click the RSS 2.0 feed, please


Kind Regards, Stoebi




Edited 3 time(s). Last edit at 12/07/2004 02:09AM by Stoebi.
Re: RSS feed creation for whole Phorum
December 07, 2004 03:45AM
from php site:

It is possible to suppress error messages from foreach, using type casting:
<?
foreach((array)$myarr as $myvar) {
...
}
?>

---
-=[ Panu ]=-
Re: RSS feed creation for whole Phorum
December 07, 2004 04:58AM
if you want you feed to be seen within firefox without 'feed viewer' you can provide a css for the xml file generated by rss.php :

replace :
$data.="<rss version=\"2.0\">\n";

by :
$data.="<?xml-stylesheet type=\"text/css\" href=\"path/to/a/stylesheet.css\" ?>\n" ;
$data.="<rss version=\"2.0\">\n";

a sample stylesheet can be find here :
rss.css
Re: RSS feed creation for whole Phorum
December 09, 2004 11:07AM
Panu Wrote:
-------------------------------------------------------
> from php site:
>
> It is possible to suppress error messages from
> foreach, using type casting:
<?
> foreach((array)$myarr as $myvar) {
> ...
> }
> ?>
>
> -=[ Panu ]=-

That can result in some add things in arrays.

If you have $x=1 and type cast it, the array is:

$x['scalar']=1;

It creates an associative array from the scalar data. not a good thing. It would be better to wrap it in an if.

Brian - Personal Blog
if locale not set make it other language will display errors
December 28, 2004 07:07AM
rss.php line 98 shoule change as:
$data ="<?xml version=\"1.0\" encoding=\"$channel[language]\" ?>\n";

and the language file must set your language
eg:
$PHORUM['locale']="GB2312";

Sorry, only registered users may post in this forum.

Click here to login