I did not include my website url, it is a vbulletin forum and all rss/xml options are enabled. (that i know of anyways)
<?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>';
}}
?>
This is the code i am using. I didnt have the date on it before but i figured that out by going through my rss2 feed from my forum. However, i cannot figure out how to get who the author of the post is to appear. When i reviewed the rss2 page the only reference to a author i can find is the dc:creator variable. Which i tried adding to my code. However i keep getting a
Parse error: syntax error, unexpected ‘:’ in /public_html/bfdm/1/rss.php on line 16
It apparently does not like the :.
I have tried using the DOM load ( $xml = new DOMDocument();
$xml->load($feed); ) but neither work.
Basically i just want to pull the subject, date, user and thread content from my Vbulletin posts. Its been driving me crazy for days.
Now all of a sudden im getting
Warning: simplexml_load_file() expects parameter 1 to be string, resource given in /public_html/bfdm/1/rss.php on line 6
On the code above with
This should work (or at least working when it has a
-):And the same has to be done with some other special characters in name, like
-.Edit: not in this case. However, the final, working code should be: