VBulletin RSS提要到主网站

VBulletin RSS提要到主网站

问题描述:

我没有包含我的网站网址,它是一个vbulletin论坛,所有rss/xml选项都已启用。 (我知道反正)VBulletin RSS提要到主网站

<?php 
// this is the url of the rss feed that you want to display 
$feed = curl_init('http://myvbforum.com/external.php?type=rss2&forumid=33'); 
curl_setopt($feed, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($feed, CURLOPT_HEADER, 0); 
$xml = simplexml_load_file($feed); 
curl_close($feed); 
//if the feed exists, then continue... 
if ($xml!=''){ 
foreach ($xml->channel->item as $item){ 
// create variables from the title and description (can also be used for images and links) 
$title = $item->title; 
$description = $item->description; 
$date = $item->pubDate; 
$user = $item->dc:creator; 
// displays the title and description on your website, formatted any way you want 
echo '<p><b>'.$title.'</b> - On '.$date.' by '.$user.' <br />'.$description.'</p>'; 
}} 
?> 

这是我使用的代码。我没有之前的日期,但我想通过从我的论坛通过我的rss2饲料了。但是,我无法弄清楚如何得到帖子作者的出现。当我回顾了rss2页面时,唯一可以找到的作者是dc:creator变量。我试图添加到我的代码。不过,我不断收到一个

解析错误:语法错误,意外“:”在/public_html/bfdm/1/rss.php在线16

它显然不喜欢。我试过使用DOM负载($ xml = new DOMDocument(); $ xml-> load($ feed);)但都不工作。

基本上我只是想从我的Vbulletin帖子中提取主题,日期,用户和主题内容。它让我疯狂了好几天。

现在突然即时得到

警告:使用simplexml_load_file()预计参数1为字符串,资源在/public_html/bfdm/1/rss.php给出的第6行

在代码以上

这应该工作(或者至少工作时,它有一个-):

$user = $item->{'dc:creator'}; 

而同样必须与其他一些规范进行名字中的ial字符,如-

编辑:不是在这种情况下。但是,最终,工作代码应该是:

<?php 
// this is the url of the rss feed that you want to display 
$feed = 'URL OF THE RSS'; //replace this with the RSS's URL 
$xml = simplexml_load_file($feed); 
//if the feed exists, then continue... 
if ($xml!=''){ 
foreach ($xml->channel->item as $item){ 
// create variables from the title and description (can also be used for images and links) 
$title = $item->title; 
$description = $item->description; 
$date = $item->pubDate; 
$user = $item->children('dc', true)->creator; 
// displays the title and description on your website, formatted any way you want 
echo '<p><b>'.$title.'</b> - On '.$date.' by '.$user.' <br />'.$description.'</p>'; 
}} 
?> 
+0

新的问题是,这 警告:使用simplexml_load_file()预计参数1为字符串,资源在/public_html/bfdm/1/rss.php给出的第6行 不知道为什么它突然给(在我尝试使用你的建议之前) – SynSe7en 2012-02-12 07:31:51

+0

使用'$ feed ='http://myvbforum.com/external.php?type = rss2&forumid = 33';'它会起作用。不需要卷曲。 – axiomer 2012-02-12 07:35:03

+0

它给了我几个卷曲错误,但即时猜测多数民众赞成在尝试从一个不存在的卷曲调用的问题。但是,海报名称仍然没有出现。这是vbulletins RSS2的问题吗?用rss代替它可能吗? – SynSe7en 2012-02-12 08:04:29