[advanced search]
 

Go Back   NamePros.com > Discussion > Web Design & Development > Programming

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.


Closed Thread
 
LinkBack Thread Tools
Old 10-29-2005, 10:42 AM   #1 (permalink)
Barru.
 
Barrucadu's Avatar
 
Join Date: Aug 2005
Location: East Yorkshire, England
Posts: 2,731
78.50 NP$ (Donate)

Barrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to beholdBarrucadu is a splendid one to behold


RSS Feeds

How would I display a BBC News RSS feed on my site? what code would I use? Also I looked on the bbc site, there is a bbc news rss feed but I dont know how to use it.
Barrucadu is offline  
Old 10-29-2005, 02:47 PM   #2 (permalink)
Senior Member
 
majinbuu1023's Avatar
 
Join Date: Jan 2005
Location: New Zealand
Posts: 3,759
85.67 NP$ (Donate)

majinbuu1023 is a splendid one to beholdmajinbuu1023 is a splendid one to beholdmajinbuu1023 is a splendid one to beholdmajinbuu1023 is a splendid one to beholdmajinbuu1023 is a splendid one to beholdmajinbuu1023 is a splendid one to beholdmajinbuu1023 is a splendid one to behold


YES - I also want to know how to do this.. thank you
majinbuu1023 is offline  
Old 10-29-2005, 03:50 PM   #3 (permalink)
Senior Member
 
commes's Avatar
 
Join Date: May 2005
Location: Regina, Sask, Canada
Posts: 1,323
36.55 NP$ (Donate)

commes is just really nicecommes is just really nicecommes is just really nicecommes is just really nice


i have no idea i have tried to put rss feeds on my site nefore, nut they have never worked, so i've been looking aroud here but i still havent found anything really
commes is offline  
Old 10-29-2005, 05:33 PM   #4 (permalink)
NPQ's PA, Slave, and On Call Coder

Technical Services


 
Eric's Avatar
 
Join Date: Mar 2005
Posts: 4,545
0.71 NP$ (Donate)

Eric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond reputeEric has a reputation beyond repute

Save a Life Child Abuse 9/11/01 :: Never Forget Baby Health Marrow Donor Program AIDS/HIV Breast Cancer Cystic Fibrosis Ethan Allen Fund Animal Cruelty Ethan Allen Fund Ethan Allen Fund Cancer Alzheimer's Protect Our Planet Cancer Survivorship SIDS Child Abuse
? Well you'll need something to parse the feed and output it as html. Which can be done with PHP. There are plenty of RSS readers/parsers. Just do a quick google search and you'll find quite a few.
__________________
Eric is offline  
Old 10-29-2005, 05:39 PM   #5 (permalink)
NamePros Regular
 
Join Date: May 2004
Location: www.IPshow.com
Posts: 950
134.70 NP$ (Donate)

Virgil is a name known to allVirgil is a name known to allVirgil is a name known to allVirgil is a name known to allVirgil is a name known to allVirgil is a name known to all


Lightbulb

Try www.hotscripts.com .
__________________
Virgil is offline  
Old 10-29-2005, 07:35 PM   #6 (permalink)
Pro Coder & Designer
 
xlusive's Avatar
 
Join Date: Apr 2005
Location: Netherlands
Posts: 964
101.50 NP$ (Donate)

xlusive is just really nicexlusive is just really nicexlusive is just really nicexlusive is just really nicexlusive is just really nice


do you guys are lookin for something like this?

http://npgeek.com/feed_rss_beta.php
__________________
Online Dragonball Game
xlusive is offline  
Old 10-29-2005, 08:02 PM   #7 (permalink)
Account Closed
 
axilant's Avatar
 
Join Date: May 2004
Location: /etc/passwd
Posts: 2,194
0.00 NP$ (Donate)

axilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to beholdaxilant is a splendid one to behold


Class:
PHP Code:
<?PHP
class RSS_Parser {
    var
$default_cp = 'UTF-8';
    var
$CDATA = 'nochange';
    var
$cp = '';
    var
$items_limit = 0;
    var
$stripHTML = False;
    var
$date_format = '';
    var
$channeltags = array ('title', 'link', 'description', 'language', 'copyright', 'managingEditor', 'webMaster', 'lastBuildDate', 'rating', 'docs');
    var
$itemtags = array('title', 'link', 'description', 'author', 'category', 'comments', 'enclosure', 'guid', 'pubDate', 'source');
    var
$imagetags = array('title', 'url', 'link', 'width', 'height');
    var
$textinputtags = array('title', 'description', 'name', 'link');

    function
Get($rss_url)
    {
        if (
$this->cache_dir != '')
        {
            
$cache_file = $this->cache_dir . '/rsscache_' . md5($rss_url);
            
$timedif = @(time() - filemtime($cache_file));
            if (
$timedif < $this->cache_time)
            {
                
$result = unserialize(join('', file($cache_file)));                
                if (
$result)
                {
                    
$result['cached'] = 1;
                }            
            }
            else
            {
                
$result = $this->Parse($rss_url);
                
$serialized = serialize($result);
                if (
$f = @fopen($cache_file, 'w'))
                {
                    
fwrite ($f, $serialized, strlen($serialized));
                    
fclose($f);
                }
                if(
$result)
                {
                    
$result['cached'] = 0;
                }
            }
        }
        else
        {
            
$result = $this->Parse($rss_url);
            if(
$result)
            {
                
$result['cached'] = 0;
            }
        }
        return
$result;
    }
    function
my_preg_match ($pattern, $subject)
    {
        
preg_match($pattern, $subject, $out);
        if(isset(
$out[1]))
        {
            if(
$this->CDATA == 'content')
            {
                
$out[1] = strtr($out[1], array('<![CDATA['=>'', ']]>'=>''));
            }
            elseif(
$this->CDATA == 'strip')
            {
                
$out[1] = strtr($out[1], array('<![CDATA['=>'', ']]>'=>''));
            }
            if(
$this->cp != '')
            {
                
$out[1] = iconv($this->rsscp, $this->cp.'//TRANSLIT', $out[1]);
            }
            return
trim($out[1]);
        }
        else
        {
            return
'';
        }
    }


    function
unhtmlentities($string) {

        
$trans_tbl = get_html_translation_table(HTML_ENTITIES, ENT_QUOTES);
        
$trans_tbl = array_flip ($trans_tbl);      
        
$trans_tbl += array('&apos;' => "'");
        return
strtr($string, $trans_tbl);
    }

    function
Parse($rss_url) {

        if(
$f = @fopen($rss_url, 'r'))
        {
            
$rss_content = '';
            while (!
feof($f))
            {
                
$rss_content .= fgets($f, 4096);
            }
            
fclose($f);
            
$result['encoding'] = $this->my_preg_match("'encoding=[\'\"](.*?)[\'\"]'si", $rss_content);
            if (
$result['encoding'] != '')
            {
                
$this->rsscp = $result['encoding'];
            }

            else
            {
                
$this->rsscp = $this->default_cp;
            }
            
preg_match("'<channel.*?>(.*?)</channel>'si", $rss_content, $out_channel);
            foreach(
$this->channeltags as $channeltag)
            {
                
$temp = $this->my_preg_match("'<$channeltag.*?>(.*?)</$channeltag>'si", $out_channel[1]);
                if(
$temp != '')
                {
                    
$result[$channeltag] = $temp;
                }
            }
            if (
$this->date_format != '' && ($timestamp = strtotime($result['lastBuildDate'])) !==-1)
            {
                
$result['lastBuildDate'] = date($this->date_format, $timestamp);
            }
            
preg_match("'<textinput(|[^>]*[^/])>(.*?)</textinput>'si", $rss_content, $out_textinfo);            
            if (isset(
$out_textinfo[2]))
            {
                foreach(
$this->textinputtags as $textinputtag)
                {
                    
$temp = $this->my_preg_match("'<$textinputtag.*?>(.*?)</$textinputtag>'si", $out_textinfo[2]);
                    if (
$temp != '')
                    {
                        
$result['textinput_'.$textinputtag] = $temp;
                    }
                }
            }
           
            
preg_match("'<image.*?>(.*?)</image>'si", $rss_content, $out_imageinfo);
            if (isset(
$out_imageinfo[1]))
            {
                foreach(
$this->imagetags as $imagetag)
                {
                    
$temp = $this->my_preg_match("'<$imagetag.*?>(.*?)</$imagetag>'si", $out_imageinfo[1]);
                    if (
$temp != '')
                    {
                        
$result['image_'.$imagetag] = $temp;
                    }
                }
            }
            
            
preg_match_all("'<item(| .*?)>(.*?)</item>'si", $rss_content, $items);
            
$rss_items = $items[2];
            
$i = 0;
            
$result['items'] = array();
            foreach(
$rss_items as $rss_item)
            {

                if (
$i < $this->items_limit || $this->items_limit == 0)
                {
                    foreach(
$this->itemtags as $itemtag)
                    {
                        
$temp = $this->my_preg_match("'<$itemtag.*?>(.*?)</$itemtag>'si", $rss_item);
                        if (
$temp != '')
                        {
                            
$result['items'][$i][$itemtag] = $temp;
                        }
                    }

                    if(
$this->stripHTML && $result['items'][$i]['description'])
                    {
                        
$result['items'][$i]['description'] = strip_tags($this->unhtmlentities(strip_tags($result['items'][$i]['description'])));
                    }

                    if(
$this->stripHTML && $result['items'][$i]['title'])
                    {
                        
$result['items'][$i]['title'] = strip_tags($this->unhtmlentities(strip_tags($result['items'][$i]['title'])));
                    }

                    if(
$this->date_format != '' && ($timestamp = strtotime($result['items'][$i]['pubDate'])) !==-1)
                    {

                        
$result['items'][$i]['pubDate'] = date($this->date_format, $timestamp);
                    }

                    
$i++;
                }
            }

            
$result['items_count'] = $i;
            return
$result;
        }
        else
        {
            return
False;
        }
    }
}
?>
Example use:
PHP Code:
$rss = new RSS_Parser();
$rss->cache_dir = "./temp";
$rss->cache_time = "1200";
$rss->maxresults = "25";
$url = "xml file url";
if (
$rs = $rss->get("$url"))
{
    if (
$rs[image_url] != '')
    {
             print(
"<a href=\"$rs[image_link]\"><img src=\"$rs[image_url]\" alt=\"$rs[image_title]\" vspace=\"1\" border=\"0\" /></a><br />\n");
    }
    print(
"<big><b><a href=\"$rs[link]\">$rs[title]</a></b></big><br />\n");
    print(
"$rs[description]<br />\n");
    print(
"<ul>\n");
    
$i = "0";
    foreach(
$rs['items'] as $item)
    {
        
$i++;
            if(
$i <= $rss->maxresults)
        {
                print(
"\t<li><div class=newstitle><a href=\"$item[link]\" target=\"_new$i\">".$item['title']."</a></div>".$item['description']."</li><br />\n");
            }
    }
    print(
"</ul>\n");
}
else
{
    print(
"Error: It's not possible to reach RSS file...\n");
}
http://serversidenews.com i developed that site making a layout for it (its been changed since it was sold) and i put that as the content. Pretty straight forward.

Rep if used please
axilant is offline  
Old 10-29-2005, 08:30 PM   #8 (permalink)
Senior Member
 
Join Date: Aug 2002
Posts: 1,300
2.85 NP$ (Donate)

deadserious has a spectacular aura aboutdeadserious has a spectacular aura about


If you aren't experienced with coding or just want a quick and easy way to add any rss feed to your Website, you can try this rss tool at the Rss Feed Help Website.
deadserious is offline  
Old 10-31-2005, 04:53 AM   #9 (permalink)
First Time Poster!
 
Join Date: Oct 2005
Posts: 1
2.00 NP$ (Donate)

The Incredible is an unknown quantity at this point


hi!

i'm very new to this forum, only 15yrs old n dont know abt these. but my blog is having an icon with RSS written on it in the url bar. wat is it. wat is RSS, wat is CSS??

kindly help.
The Incredible is offline  
Old 10-31-2005, 05:04 AM   #10 (permalink)
KPR
Senior Member
 
KPR's Avatar
 
Join Date: May 2005
Location: Sunny Scotland
Posts: 1,758
34.00 NP$ (Donate)

KPR has much to be proud ofKPR has much to be proud ofKPR has much to be proud ofKPR has much to be proud ofKPR has much to be proud ofKPR has much to be proud ofKPR has much to be proud ofKPR has much to be proud ofKPR has much to be proud of


You can use wordpress with a plugin that will pull news from sites and display them on your site in different catogories giving it a similiar feel to the way topix works.

http://wordpress.org/

http://codex.wordpress.org/Plugins/Syndication

Heres a good one.
http://projects.radgeek.com/feedwordpress
KPR is offline  
Old 10-31-2005, 05:22 AM   #11 (permalink)
Senior Member
 
Peter's Avatar
 
Join Date: Nov 2003
Location: Scotland
Posts: 4,900
0.60 NP$ (Donate)

Peter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond reputePeter has a reputation beyond repute

Child Abuse Save The Children Save The Children Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009 Help The Homeless - Holiday 2009
Quote:
Originally Posted by The Incredible
hi!

i'm very new to this forum, only 15yrs old n dont know abt these. but my blog is having an icon with RSS written on it in the url bar. wat is it. wat is RSS, wat is CSS??

kindly help.
CSS is cascading style sheets and is used for design and layout of web pages. More info can be found at http://www.w3.org/Style/CSS/

RSS is used for syndicating news articles, Ussually to allow other people to display that news on their own web site or in a program such as feedreader (http://www.feedreader.com/)
Peter is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Interesting feature on RSS FEEDS equity78 Domain Name Discussion 0 07-11-2005 12:19 PM
RSS Feeds for domain realted topics EbookLover Domain Name Discussion 5 07-08-2005 09:11 PM
Free Web-based RSS Feeds: Rojo Dave in Carthage Free Resources 0 05-08-2005 10:37 PM
RSS News Feeds Webtwink Website Development 9 09-13-2003 03:33 AM

Site Sponsors
Advertise your business at NamePros

All times are GMT -7. The time now is 05:22 PM.


Powered by: vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Template-Modifications by TMS
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85