Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

[ NEW PLUGIN ] BBC_News [ FREE ]

(Page 1 of 2)
> >
Quote Reply
[ NEW PLUGIN ] BBC_News [ FREE ]
Here's a little plugin for those of you wanting to make use of the BBC's RSS/XML news feed's.

You can download the plugin from here: http://ultranerds.com/...?g=Detailed/152.html

Very simple to install and Free Angelic

Enjoy!

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] [ NEW PLUGIN ] BBC_News [ FREE ] In reply to
Wow.. another wonderful plugin from Andy.

Hey Andy, thanks a lot (from me and whole community) for helping us out.

Vishal

Vishal
-------------------------------------------------------
Quote Reply
Re: [SWDevil.Com] [ NEW PLUGIN ] BBC_News [ FREE ] In reply to
Hi,

Thanks Cool

It's been a while since I released a free plugin, so I thought I'd have a go <G>

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] [ NEW PLUGIN ] BBC_News [ FREE ] In reply to
Hi Andy,

If the RSS feed is down for whatever reason, the page just returns blank.
Is there a way for some error handing so a small messages is displayed if no feed is available?

I tried this code addition but no luck I'm afraid:

Code:
sub GetNews {

my $feed_url = $_[0];

if ($feed_url !~ /(.*?)bbc\.co\.uk\/(.*?).xml/) {
return "No RSS feed URL passed in!";
}

use LWP::Simple;
use Data::Dumper;
my @page = get($feed_url);
my $page = join("",@page);

die "Request failed\n" unless defined($feed_url);

use XML::Simple;
my $ref = XMLin($page);

my $count = $ref->{channel}->{ttl} || 0;

my @news;
for (my $i = 0; $i < $count; $i++) {
push @news, $ref->{channel}->{item}[$i];
}

return { 'news.title' => $ref->{channel}->{title},
news_loop => \@news, 'news.dump' => Dumper($ref->{channel}) };

}

~ ERASER


Free JavaScripts @ Insight Eye

Last edited by:

Eraser: Sep 1, 2007, 3:41 AM
Quote Reply
Re: [Eraser] [ NEW PLUGIN ] BBC_News [ FREE ] In reply to
Hi,

I would try:

Code:
my $page = join("",@page);

if (!$page[0]) {
return "Request failed";
}

Hope that helps.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] [ NEW PLUGIN ] BBC_News [ FREE ] In reply to
Hi Andy,
can I change this line to just the rss feed of my choice,

Code:
if ($feed_url !~ /(.*?)bbc\.co\.uk\/(.*?).xml/) {

or is it only for bbc feeds?

Thanks
Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] [ NEW PLUGIN ] BBC_News [ FREE ] In reply to
Hi,

It will only work with the BBC RSS feed, as it has pre-defined formatting (i.e the format of another RSS feed will no doubt be different / use different field names, etc)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] [ NEW PLUGIN ] BBC_News [ FREE ] In reply to
Hi Andy,
mmh, so what about a plugin as example for google news.
A plugin that can defined with 1-3 keywords in order to show only news that fit to the site.

And I think google news are the same all over the world. So you just have to change the url and you can show the news in the prefered language.
This would be a interesting News Plugin for much more people, than BBC News.

Am I dreaming or is this doable?

Thanks
Matthias

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] [ NEW PLUGIN ] BBC_News [ FREE ] In reply to
Mmm.. I'll see what I can do. I've been doing a bit too much free stuff recently :D

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] [ NEW PLUGIN ] BBC_News [ FREE ] In reply to
Andy wrote:
Mmm.. I'll see what I can do. I've been doing a bit too much free stuff recently :D

Cheers

Hi Andy,
why are you doing it for free.
Do it as a paid plugin, but please put it in the Gossamer Links ULTRA Package Wink

Thanks
Matthias


Matthias
gpaed.de
Quote Reply
Re: [Matthias70] [ NEW PLUGIN ] BBC_News [ FREE ] In reply to
Hi,

Its not really something worth charging for =) I'll see what I can do (although not today, as its Sunday - and I've already been working all week :P)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] [ NEW PLUGIN ] BBC_News [ FREE ] In reply to
Have a nice sunday Smile
Thanks
Andy

Matthias
gpaed.de
Quote Reply
Re: [Matthias70] [ NEW PLUGIN ] BBC_News [ FREE ] In reply to
Hi,

I had a look into this, but for some reason, the RSS feeds don't seem to work :(

I'm just testing it with something simple:

Code:
#!/usr/bin/perl -w

use strict;
use CGI::Carp qw(fatalsToBrowser);
print "Content-Type: text/html \n\n";

my $feed_url = q|http://news.google.com/?ned=us&topic=t&output=rss|;

print $feed_url;

use LWP::Simple;
use Data::Dumper;
my @page = get($feed_url);

print join("",@page);

.. but the contents are blank. Not sure why thats happening, but without being able to get the data from that test page, I can't do anything :(

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] [ NEW PLUGIN ] BBC_News [ FREE ] In reply to
Andy wrote:

.. but the contents are blank. Not sure why thats happening, but without being able to get the data from that test page, I can't do anything :(

Cheers

Hi Andy,
I would if I could help, but I have no idea how to fix it?
Matthias

Matthias
gpaed.de
Quote Reply
Re: [Andy] [ NEW PLUGIN ] BBC_News [ FREE ] In reply to
Hi Andy,

Looking at several of the BBC feeds I see they also have images but in this format:

<media:thumbnail width="66" height="49" url="http://newsimg.bbc.co.uk/media/images/44232000/jpg/_44232128_cenotaph_66pic.jpg" />

so I thought of grabbing that url= by using:

<%media:thumbnail.url%>

but I get a Unknown Tag error.

Any ideas on this - perhaps I'm using the wrong format to get the url within media:thumbnail?

~ ERASER


Free JavaScripts @ Insight Eye
Quote Reply
Re: [Eraser] [ NEW PLUGIN ] BBC_News [ FREE ] In reply to
Hi,

Have you actually managed to get this plugin working with a BBC feed? I tried a little while back, and it didn't seem to be recognized :(

Regarding the images - its not as simple as that. You need to add in some more XML codes to extract the image URL and details.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] [ NEW PLUGIN ] BBC_News [ FREE ] In reply to
Yeah, I 'think' I changed this to make it work:

my $count = $ref->{channel}->{ttl} || 0;

my $count = $ref->{channel}->{ttl} || 4320;

Any chance on doing the img stuff?

~ ERASER


Free JavaScripts @ Insight Eye
Quote Reply
Re: [Eraser] [ NEW PLUGIN ] BBC_News [ FREE ] In reply to
Hi,

Just tested this, and it seems to work.

Code:
sub GetNews {

my $feed_url = $_[0];

if ($feed_url !~ /(.*?)bbc\.co\.uk\/(.*?).xml/) {
return "No RSS feed URL passed in!";
}

use LWP::Simple;
use Data::Dumper;
my @page = get($feed_url);
my $page = join("",@page);

use XML::Simple;
my $ref = XMLin($page);

my $count = $ref->{channel}->{ttl} || 0;

my @news;
for (my $i = 0; $i < $count; $i++) {
$ref->{channel}->{item}[$i]->{image} = $ref->{channel}->{item}[$i]->{'media:thumbnail'}->{url};
push @news, $ref->{channel}->{item}[$i];

}

return { 'news.title' => $ref->{channel}->{title}, news_loop => \@news, 'news.dump' => Dumper($ref->{channel}) };

}

Just call with <img src="<%image%>" /> in the loop

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] [ NEW PLUGIN ] BBC_News [ FREE ] In reply to
Hey Andy this is good stuff.

Many thanks for this.

~ ERASER


Free JavaScripts @ Insight Eye
Quote Reply
Re: [Andy] [ NEW PLUGIN ] BBC_News [ FREE ] In reply to
 
I had to change the position of your new code as I kept getting repeated images. Seems OK though, any significance in this change?


my @news;
for (my $i = 0; $i < $count; $i++) {
push @news, $ref->{channel}->{item}[$i];
$ref->{channel}->{item}[$i]->{image} = $ref->{channel}->{item}[$i]->{'media:thumbnail'}->{url};
}

~ ERASER


Free JavaScripts @ Insight Eye

Last edited by:

Eraser: Nov 12, 2007, 2:39 AM
Quote Reply
Re: [Eraser] [ NEW PLUGIN ] BBC_News [ FREE ] In reply to
Hi,

Are you sure?

I just did a test - and works fine:

http://gossamerlinks.com/.../dev/page.cgi?p=test

That is using this loop:

Code:
<%Plugins::BBC_News::GetNews("http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml")%>

Title: <%news.title%><br/> <%-- This is the title of the particular RSS feed you selected --%>

<%loop news_loop%>
Title: <%title%><br/>
URL: <%link%><br/>
Description: <%description%><br/>
<%if image%><img src="<%image%>" /><%endif%>
<br/>
<%endloop%>

Placing the code where you are now (in your last post), will not work - as it has already passed in the hashref into the array (the line before), so anything after that will just be ignored =)

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] [ NEW PLUGIN ] BBC_News [ FREE ] In reply to
Opps - I have to admit to using a hacked version of that plugin Tongue

In the original all is fine as you correctly stated.

Thanks again!

~ ERASER


Free JavaScripts @ Insight Eye
Quote Reply
Re: [Eraser] [ NEW PLUGIN ] BBC_News [ FREE ] In reply to
Hi,

No problem Tongue

I've also edited the main plugin, so 1.1. is now available (with this change).

Anyone who's interested, its attached.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] [ NEW PLUGIN ] BBC_News [ FREE ] In reply to
Hi Andy,

Can you make the URL to the news feeds clickable?

URL: <%link%><br/> shows URL but can go to the news!


Thanks for the plugin.
Quote Reply
Re: [rascal] [ NEW PLUGIN ] BBC_News [ FREE ] In reply to
Hi,

Sorry, I'm not sure what your asking?

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
> >