Feed::Source::Page2RSS - Creation of a Atom/RSS feed with the Page2RSS service


Feed-Source-Page2RSS documentation Contained in the Feed-Source-Page2RSS distribution.

Index


Code Index:

NAME

Top

Feed::Source::Page2RSS - Creation of a Atom/RSS feed with the Page2RSS service

VERSION

Top

Version 0.01

SYNOPSIS

Top

Page2RSS create a Atom/RSS feed to monitor a webpage. This module help you to create these feeds.

  use Feed::Source::Page2RSS;

  my $feed = Feed::Source::Page2RSS->new( url => "http://www.google.com", feed_type => "rss" );
  my $feed_url = $feed->url_feed();

  or

  my $feed = Feed::Source::Page2RSS->new( url => "http://www.google.com" );
  my $atom = $feed->atom_feed();

  is equivalent to 

  my $feed = Feed::Source::Page2RSS->new( url => "http://www.google.com" );
  $feed->feed_type('atom');
  my $atom = $feed->url_feed();

  or

  my $feed = Feed::Source::Page2RSS->new( url => "http://www.google.com" );
  my $rss = $feed->rss_feed();

  is equivalent to 

  my $feed = Feed::Source::Page2RSS->new( url => "http://www.google.com" );
  $feed->feed_type('rss');
  my $rss = $feed->url_feed();

FUNCTIONS

Top

new

Constructor of the Feed::Source::Page2RSS object. You can spcecify the following options :

url

URL to monitor

feed_type

Feed type of the returned URL. Possible values are RSS and Atom.

feed_type

Adjust the feed type. Possible value are RSS and Atom.

url_feed

Return the URL feed.

atom_feed

Return the Atom URL feed.

rss_feed

Return the RSS URL feed.

AUTHOR

Top

Emmanuel Di Pretoro, <<manu at bjornoya.net>>

BUGS

Top

Please report any bugs or feature requests to bug-feed-source-page2rss at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Feed-Source-Page2RSS. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

Top

You can find documentation for this module with the perldoc command.

    perldoc Feed::Source::Page2RSS

You can also look for information at:

* AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/Feed-Source-Page2RSS

* CPAN Ratings

http://cpanratings.perl.org/d/Feed-Source-Page2RSS

* RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Feed-Source-Page2RSS

* Search CPAN

http://search.cpan.org/dist/Feed-Source-Page2RSS

SEE ALSO

Top

Page2RSS http://page2rss.com

COPYRIGHT & LICENSE

Top


Feed-Source-Page2RSS documentation Contained in the Feed-Source-Page2RSS distribution.
package Feed::Source::Page2RSS;

use warnings;
use strict;

use Carp;
use URI;
use constant {
  RSS => "http://page2rss.com/page/rss",
  ATOM => "http://page2rss.com/page/atom",
};

our $VERSION = '0.01';

sub new {
  my ($class, %args) = @_;
  my $self;
  $self->{params}{url} = $args{url} if exists $args{url};
  $self->{feed_type} = uc $args{feed_type} || "RSS";
  bless $self, $class;
  $self;
}

sub feed_type {
  my $self = shift;
  $self->{feed_type} = uc shift if @_;
}

sub url_feed {
  my $self = shift;
  if (exists $self->{params}{url}) {
    my $uri;
    if ($self->{feed_type} eq "RSS") {
      $uri = URI->new(RSS);
    } else {
      $uri = URI->new(ATOM)
    }
    $uri->query_form( $self->{params} );
    return $uri->as_string();
  } else {
    croak "You must specify an URL to monitor";
  }
  
}

sub atom_feed {
  my $self = shift;
  if (exists $self->{params}{url}) {
    my $uri = URI->new(ATOM);
    $uri->query_form( $self->{params} );
    return $uri->as_string();
  } else {
    croak "You must specify an URL to monitor";
  }
  
}

sub rss_feed {
  my $self = shift;
  if (exists $self->{params}{url}) {
    my $uri = URI->new(RSS);
    $uri->query_form( $self->{params} );
    return $uri->as_string();
  } else {
    croak "You must specify an URL to monitor";
  }
  
}


1; # End of Feed::Source::Page2RSS