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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.