Jump to content

MagpieRSS with PHP code problem


lmandrake

Recommended Posts

Hello,

 

I'm a total PHP newbie and am hoping someone can help me with some code which I can't seem to get to work.

I have magpie RSS installed on my server and am trying to use it to display data from an RSS xml feed, in a specific way. I managed to get a crude version to work which would only display the title of the article as a link to the original page.

I am trying to get something more advanced so that the php code pulls, the title, link of the article, date and then part of the description and displays it as:

 

<a href="link">title</a>, month/day/year -- "description"

<a href="link">title</a>, month/day/year -- "description"

etc..

 

I would also like to be able to limit the size of the description to the first 100 characters.

 

Can anyone help?

Thanks!!

 

Here's my coding attempt:

<?php

include('rss/rss_fetch.inc');

$url =

 

"http://www.voanews.com/english/customCF/RecentStoriesRSS.cfm?

 

keyword=TopStories";

$rss_data = fetch_rss($url);

if ($rss) {

 

 

foreach ($rss_data->items as $rss_item ) {

$rss_title = $rss_item['title'];

$item_link = $rss_item['link'];

$rss_pubDate = $rss_item['date_timestamp'];

$rss_description = $rss_item['description'];

echo "<p><a href=$item_link>$rss_title</a> - " . date("m/d/Y",

 

$rss_pubDate) . " - ". $rss_description ."\n";

}

?>

 

Link to comment
https://forums.phpfreaks.com/topic/147053-magpierss-with-php-code-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.