`
天梯梦
  • 浏览: 13730964 次
  • 性别: Icon_minigender_2
  • 来自: 洛杉矶
社区版块
存档分类
最新评论

RSS Feed Generator for PHP (兼有podcast rss - iTunes )

阅读更多

RSS Feed 生成。

 

现在是两个版本,第一个适合新闻类的rss,我做了第二个版本,添加了iTunes Rss, 适合苹果机的podcast。

 

版本一实例:(内附说明文档)

 

<?php

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 (my name)';
$rss_channel->webMaster = 'webmaster@mysite.com (my name)';

/*
$image = new rssGenerator_image();
$image->title = $rss_channel->title;
$image->url = 'http://graphics.nytimes.com/images/section/NytSectionHeader.gif';
$image->link = 'http://www.phpclasses.org/graphics/logo.gif';
$rss_channel->image = $image;
*/


$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_feed = new rssGenerator_rss();
$rss_feed->encoding = 'UTF-8';
$rss_feed->version = '2.0';
header('Content-Type: text/xml');
echo $rss_feed->createFeed($rss_channel);
 

 

 

版本二实例:

 

<?php
@session_start();
require_once("include/db.php");
	$open_DB = new db;
	$open_DB -> connect();

require_once 'rss_generator.inc.php';

$rss_channel = new rssGenerator_channel();
$rss_channel->atomLinkHref = '';

$rss_channel->title = 'The javaeye > Podcast Download';
$rss_channel->link = 'http://www.iteye.com';
$rss_channel->description = 'an audio podcast dramatic series -- created by Gideon';
$rss_channel->language = 'en-us';
$rss_channel->generator = 'The javaeye RSS Feed';
$rss_channel->managingEditor = 'nlewis@justcoding.com (Neil Lewis)';
$rss_channel->webMaster = 'rnelson@justcoding.com (Reginald Nelson)';
$rss_channel->copyright = 'Copyright © 2010 The justcoding.javaeye. All rights reserved';
$rss_channel->iauthor = 'The Primordials';
$rss_channel->isubtitle = 'an audio podcast dramatic series';
$rss_channel->isummary = 'an audio podcast dramatic series -- created by Gideon';
$rss_channel->iowner = true;
$rss_channel->iname = 'Neil Lewis';
$rss_channel->iemail = 'rnelson@justcoding.com';


/*
$image = new rssGenerator_image();
$image->title = $rss_channel->title;
$image->url = 'http://graphics.nytimes.com/images/section/NytSectionHeader.gif';
$image->link = 'http://www.phpclasses.org/graphics/logo.gif';
$rss_channel->image = $image;
*/

// display information
$sql="SELECT * FROM `music` ORDER BY `id` ASC Limit 0,8";
$result = @mysql_query($sql);
$i = 0;
while($row = @mysql_fetch_object($result))
{
	$item = new rssGenerator_item();
	$item->title = $row->title;
	$item->description = $row->chapter;
	$link = 'http://www.iteye.com/download.php?id='.$row->music;
	$guid = 'http://www.iteye.com/neil/'.$row->music;
	$item->link = $link;
	$item->guid = $guid;
	$item->enclosure_url = $guid;
	$item->enclosure_length = @filesize('neil/'.$row->music);
	$item->enclosure_type = 'm4a/mp3';
	$item->pubDate = $row->mydate;
	$item->categories = array('name'=>'Podcasts');

	$item->iauthor = 'The Primordials';
	$item->isubtitle = 'http://www.iteye.com';
	$item->isummary = 'http://www.iteye.com';
	$item->iduration = $row->mydate;
	$item->ikeywords = 'Podcasts, Music, the primordials';
	
	$rss_channel->items[] = $item;

	$i++;
}

$rss_feed = new rssGenerator_rss();
$rss_feed->encoding = 'UTF-8';
$rss_feed->version = '2.0';
header('Content-Type: text/xml');
echo $rss_feed->createFeed($rss_channel);
 

 

当然,如果你想更好的控制rss的样式,那么你就要学习XSLT了,请参看   XSLT入门

 

 

 

参考资源:

http://www.apple.com/itunes/podcasts/specs.html

http://www.podcast411.com/howto_1.html

http://www.podcast411.com/id3tags.html

 

 

 

 

分享到:
评论

相关推荐

    mybatis-generator-core-1.3.7-API文档-中文版.zip

    赠送jar包:mybatis-generator-core-1.3.7.jar; 赠送原API文档:mybatis-generator-core-1.3.7-javadoc.jar; 赠送源代码:mybatis-generator-core-1.3.7-sources.jar; 赠送Maven依赖信息文件:mybatis-generator-...

    mybatis-generator-core-1.3.5-API文档-中文版.zip

    赠送jar包:mybatis-generator-core-1.3.5.jar; 赠送原API文档:mybatis-generator-core-1.3.5-javadoc.jar; 赠送源代码:mybatis-generator-core-1.3.5-sources.jar; 包含翻译后的API文档:mybatis-generator...

    mybatis-generator-core-1.3.2

    使用mybatis-generator-core-1.3.2生成dao,mapper跟model等 使用方法:解压缩之后修改XML文件(如何改可以百度,就是换jdbc参数以及你要生成的dao,mapper跟model的名字及所在位置)然后windos下cmd然后cd到你放置...

    LoadRunner Generator for Linux

    本文主要针对“LoadRunner Generator for Linux”进行详细介绍。 ### 一、LoadRunner Generator for Linux简介 #### 1.1 LoadRunner概述 LoadRunner是一种广泛使用的负载测试工具,主要用于预测系统的行为和性能。...

    rss-feed-generator-bundle:简单的RSS提要生成器

    composer require markocupic/rss-feed-generator-bundle 选项A:将此添加到您的config / bundles.php中。 &lt;?php return [ // ... Markocupic \ RssFeedGeneratorBundle \ MarkocupicRssFeedGeneratorBundle ...

    Atom-hexo-generator-feed,为HEXO供电。为HEXOJS/HEXO做出贡献.zip

    Atom-hexo-generator-feed是专门为Hexo博客框架设计的一个插件,用于生成RSS feed,使得博客内容可以被订阅和分享。这个插件与Atom文本编辑器无关,尽管它们的名字中都包含"Atom"。这里我们将深入探讨Hexo、Atom文本...

    mybatis-generator-gui

    "mybatis-generator-gui" 是一个基于MyBatis框架的可视化工具,主要用于简化数据库映射文件(Mapper文件)的创建过程。MyBatis是一个优秀的Java持久层框架,它支持定制化SQL、存储过程以及高级映射,避免了几乎所有...

    generate-podcast-rss-cloud-function:每当将新的MP3文件添加到Cloud Storage存储桶时,Google Cloud Function都会(重新)生成Podcast RSS feed

    生成播客feed云功能这是我与一起使用的 ,可与Cloud Storage存储桶配合使用,其中包含MP3文件和Podcast RSS feed。 简而言之,每当将新文件添加到存储桶时,都会触发此Cloud Function,并(重新)为存储桶中的MP3...

    mybatis-generator-core.zip

    java -jar mybatis-generator-core-1.3.2.jar -configfile mysqlGeneratorConfig.xml -overwrite #sql server java -jar mybatis-generator-core-1.3.2.jar -configfile sqlServerGeneratorConfig.xml -overwrite ...

    mybatis-generator-core-1.3.5.jar

    mybatis-generator-core-1.3.5.jarmybatis-generator-core-1.3.5.jarmybatis-generator-core-1.3.5.jarmybatis-generator-core-1.3.5.jar

    mybatis-generator-maven-plugin-1.4.0.jar

    java运行依赖jar包

    jRSS - Simple Java RSS Feed Generator-开源

    **jRSS - 简单Java RSS Feed Generator** jRSS是一个专为Java开发者设计的开源库,用于方便快捷地创建符合RSS 2.0规范的feed。RSS(Really Simple Syndication)是一种数据格式,用于发布新闻、博客文章、播客等...

    mybatis-generator-core-1.3.5-API文档-中英对照版.zip

    赠送jar包:mybatis-generator-core-1.3.5.jar 赠送原API文档:mybatis-generator-core-1.3.5-javadoc.jar 赠送源代码:mybatis-generator-core-1.3.5-sources.jar 包含翻译后的API文档:mybatis-generator-core-...

    mybatis-plus-generator-maven-plugin-1.0.0.jar

    为了在项目中快捷方便的代码生成,将mybatis-plus-generator封装为了一个maven的插件`mybatis-plus-generator-maven-plugin。使用文档参考:https://blog.csdn.net/xiweiller/article/details/103072165

    mybatis-plus-generator-maven-plugin-1.0.0依赖的pom.xml

    mybatis-plus-generator-maven-plugin-v1.0.0依赖的pom.xml,用于mybatis-plus-generator-maven-plugin-1.0.0.jar本地仓库上传时依赖使用

    mybatis-generator-1.3.2 代码生成

    1. **mybatis-generator-core-1.3.2-javadoc.jar**:这是MyBatis Generator的API文档,包含了所有类和方法的详细说明,有助于开发者理解和使用该工具。 2. **mysql-connector-java-5.1.25-bin.jar**:这是MySQL的...

    form-generator项目集成方案.doc

    form-generator项目集成方案 form-generator项目集成方案是指将form-generator项目集成到本地项目中,以便实现表单可视化设计和生成表单代码的功能。该方案主要涉及到 Vue 项目的多页面结构、组件引入、样式文件...

    mybatis-generator.zip

    可自动生成sql的工具,包括xml(mapper), dao层接口,bean实体;含盖通用的增删改查方法; 本工具的优势:不用集成在...压缩包中有详细的使用说明,配上数据库连接,表名,待生成的代码包路径;使用方便,傻瓜式操作!

    mybatis-generator-for-imooc.zip

    在这个名为 "mybatis-generator-for-imooc.zip" 的压缩包中,我们找到了一个专门针对 Imooc 平台的 MBG 配置,它简化了在后端开发中从数据库到代码的转换过程。 首先,让我们理解 MBG 的核心功能。MBG 可以根据...

Global site tag (gtag.js) - Google Analytics