PHP是rss($url)?

PHP是rss($url)?,php,rss,Php,Rss,有没有一种方法可以通过PHP使用URL,或者通过$string=file\u get\u contents($URL)找到给定URL是否是RSS提要 我也希望能够处理作为一个潜在的问题饲料饲料类型饲料 我正在尝试根据WordPress和Blogger标准自动发现这些提要-(我不知道是否存在这种类型的东西-引用的示例将非常有用:)。一个基本的不可靠测试: $string = file_get_contents($url); if (strpos($string, '<rss') !== FA

有没有一种方法可以通过PHP使用URL,或者通过
$string=file\u get\u contents($URL)
找到给定URL是否是RSS提要

我也希望能够处理作为一个潜在的问题饲料饲料类型饲料


我正在尝试根据WordPress和Blogger标准自动发现这些提要-(我不知道是否存在这种类型的东西-引用的示例将非常有用:)。

一个基本的不可靠测试:

$string = file_get_contents($url);
if (strpos($string, '<rss') !== FALSE)) {
   ... yes, it's probably rss
}
$string=file\u get\u contents($url);

如果(strpos($string,一个基本的不可靠测试:

$string = file_get_contents($url);
if (strpos($string, '<rss') !== FALSE)) {
   ... yes, it's probably rss
}
$string=file\u get\u contents($url);
如果(strpos($string,),您可以使用优秀的库fot(处理rss、atom、Feedburner)来认真对待这项任务:

// load the simplepie class
require 'simplepie.php';
$feed = new simpepie;

$feed->set_feed_url('your url here');

$feed->enable_cache(true);
$feed->set_cache_location('cache');
$feed->set_cache_duration(1800);

$feed->init();

//let simplepie handle the content type (atom, RSS...)
$feed->handle_content_type();

if ($feed->error)
{
   // not a valid rss feed / url
   echo '<div class="box error">' . $feed->error . '</div>';
}
else
{
  // proceed
}
//加载simplepie类
需要“simplepi.php”;
$feed=新simpepie;
$feed->set_feed_url(“此处为您的url”);
$feed->enable_cache(true);
$feed->set_cache_location('cache');
$feed->set_cache_duration(1800);
$feed->init();
//让simplepie处理内容类型(atom、RSS…)
$feed->handle_content_type();
如果($feed->error)
{
//不是有效的rss源/url
回显“”。$feed->错误。“;
}
其他的
{
//进行
}
您可以使用优秀的库fot(处理rss、atom、Feedburner)来认真对待这项任务:

// load the simplepie class
require 'simplepie.php';
$feed = new simpepie;

$feed->set_feed_url('your url here');

$feed->enable_cache(true);
$feed->set_cache_location('cache');
$feed->set_cache_duration(1800);

$feed->init();

//let simplepie handle the content type (atom, RSS...)
$feed->handle_content_type();

if ($feed->error)
{
   // not a valid rss feed / url
   echo '<div class="box error">' . $feed->error . '</div>';
}
else
{
  // proceed
}
//加载simplepie类
需要“simplepi.php”;
$feed=新simpepie;
$feed->set_feed_url(“此处为您的url”);
$feed->enable_cache(true);
$feed->set_cache_location('cache');
$feed->set_cache_duration(1800);
$feed->init();
//让simplepie处理内容类型(atom、RSS…)
$feed->handle_content_type();
如果($feed->error)
{
//不是有效的rss源/url
回显“”。$feed->错误。“;
}
其他的
{
//进行
}

您想要FeedBurner Feed,还是ATOM?我已经有了一个基本的RSS解析器,我正在寻找一个自动化的RSS发现系统(使用CodeIgniter)抱歉,在我之前的评论中,我指的是RSS,或者ATOM?你想要FeedBurner提要,或者ATOM吗?我已经有了一个基本的RSS解析器,我正在寻找一个自动化的RSS发现系统(使用CodeIgniter)对不起,在我之前的评论中,我指的是RSS,或者ATOM?我已经在使用基于CodeIgniter的解析器了——不管怎样,这似乎是一个有待解决的问题——在我尝试解析它之前,没有验证它实际上是一个RSS提要?@Wallter:看看CI的库是否支持任何这样的功能,通常应该由lib来处理作为simplepie,您需要查看您正在使用的lib文档。另一个选择是使用simplepie,您应该能够将其合并到CI中。我已经在使用基于CodeIgniter的解析器-无论哪种方式,这似乎都是一个有待解决的问题-在我尝试解析它之前,不验证它实际上是RSS提要?@Wallter:查看CI是否lib支持任何这样的函数,通常这些函数应该像simplepi一样由lib处理,您需要查看正在使用的lib的文档。另一个选项是使用simplepi,您应该能够将其合并到CI中。