bizman 发表于 2009-2-10 15:04:05

一个老外写的RSS的处理东西-偶修改了一下

一个老外写的RSS的处理东西-偶修改了一下
让其支持数组。

部分代码
<?php
/*
RSS Feed Generator for PHP 4 or higher version
Version 1.0.3
Written by Vagharshak Tozalakyan <vagh@armdex.com>
License: GNU Public License

Classes in package:
    class rssGenerator_rss
    class rssGenerator_channel
    class rssGenerator_image
    class rssGenerator_textInput
    class rssGenerator_item
For additional information please reffer the documentation
或许用全对象的方式要好一些
#this version has cheaged by bizman see the orgin vesion please go to: http://www.phpclasses.org/browse/download/zip/package/2957/name/rssgen2_0-2008-05-01.zip
* about more rss infomation
*http://hi.baidu.com/idea361/blog/item/2bfd8b43cb1e821073f05da5.html
*http://hi.baidu.com/guoxinghua/blog/item/0274f23fba3407c77c1e71c6.html
* RFC-822标准时间示例:
    <pubDate>Wed, 02 Oct 2002 08:00:00 EST </pubDate>
    <pubDate>Wed, 02 Oct 2002 13:00:00 GMT </pubDate>
    <pubDate>Wed, 02 Oct 2002 15:00:00 +0200 </pubDate>
    rss check http://www.feedvalidator.org/
###demo
*/

require_once 'rss_generator.inc.php';
#方法一
$rss_channel = new rssGenerator_channel();
$rss_channel->atomLinkHref = '';
$rss_channel->title = 'My News';
$rss_channel->link = 'http://mysite.com/news.php';
$rss_channel->description = 'The latest news about web-development.';
$rss_channel->language = 'en-us';
$rss_channel->generator = 'PHP RSS Feed Generator';
$rss_channel->managingEditor = 'editor@mysite.com (Alex Jefferson)';
$rss_channel->webMaster = 'webmaster@mysite.com (Vagharshak Tozalakyan)';
$item = new rssGenerator_item();
$item->title = 'New website launched';
$item->description = 'Today I finaly launch a new website.';
$item->link = 'http://newsite.com';
$item->guid = 'http://newsite.com';
$item->pubDate = 'Tue, 07 Mar 2006 00:00:01 GMT';
$rss_channel->items[] = $item;

$item = new rssGenerator_item();
$item->title = 'Another website launched';
$item->description = 'Just another website launched.';
$item->link = 'http://anothersite.com';
$item->guid = 'http://anothersite.com';
$item->pubDate = 'Wed, 08 Mar 2006 00:00:01 GMT';
$rss_channel->items[] = $item;
#方式二
$rss_channel = array(
    'atomLinkHref'=>'',
    'title' => 'My News',
    'link' => 'http://mysite.com/news.php',
    'description' => 'The latest news about web-development.',
    'language' => 'en-us',
    'generator' => 'PHP RSS Feed Generator',
    'managingEditor' => 'editor@mysite.com (Alex Jefferson)',
    'webMaster' => 'webmaster@mysite.com (Vagharshak Tozalakyan)',
    'items'=>array(
      '0'=>array(
            'title' => 'New website launched',
            'description' => 'Today I finaly launch a new website.',
            'link' => 'http://newsite.com',
            'guid' => 'http://newsite.com',
            'pubDate' => 'Tue, 07 Mar 2006 00:00:01 GMT',
      ),
      '1'=>array(
            'title' => 'Another website launched',
            'description' => 'Just another website launched.',
            'link' => 'http://newsite.com',
            'guid' => 'http://newsite.com',
            'pubDate' => 'Wed, 08 Mar 2006 00:00:01 GMT',
      ),
    ),
);
echo rssGenerator::getInstance()->createFeed($rss_channel);
?>

WHO有时间可以看看或者修改一下

linggano 发表于 2010-12-29 17:23:09

先下来,再研究、学习!
多谢楼主!

强烈要求 Hex:“she精”!
页: [1]
查看完整版本: 一个老外写的RSS的处理东西-偶修改了一下