GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  WWW::SPINN3R (3)

.ds Aq ’

NAME

WWW::Spinn3r - An interface to the Spinn3r API (http://www.spinn3r.com)

CONTENTS

SYNOPSIS



 use WWW::Spinn3r;
 use DateTime;

 my $API = {
    vendor          => acme,   # required
    limit           => 5,
    lang            => en,
    tier            => 0:5,
    after           => DateTime->now()->subtract(hours => 48),
 };

 my $spnr = new WWW::Spinn3r (
    api => permalink3.getDelta, params => $API, debug => 1);
 );

 while(1) {
     my $item = $spnr->next;
     print $item->{title};
     print $item->{link};
     print $item->{dc}->{source};
     print $item->{description};
 }



DESCRIPTION

WWW::Spinn3r is an iterative interface to the Spinn3r API. The Spinn3r API is implemented over REST and XML and documented at http://spinn3r.com/documentation.

OBTAINING A VENDOR KEY

Spinn3r service is available through a <B>vendorB> key, which you can get from the good folks at Tailrank, http://spinn3r.com/contact.

HOW TO USE

Most commonly, you’ll need just two functions from this module: new() and next(). new() creates a new instance of the API and next() returns the next item from the Spinn3r feed, as hashref. Details are below.

<B>B>new()<B>B>

The contructor. This function takes a hash with the following keys:
<B>apiB> permalink3.getDelta or feed3.getDelta, one of the two APIs provided by Spinn3r.
<B>paramsB> These are parameters that are passed to the API call. See http://spinn3r.com/documentation for a list of available parameters and their values.

The <B>versionB> parameter to the API is a function of version of this module. and the <B>B>version()<B>B> accessor method returns the version of the API. By default, the version will be set to the version that corresponds to this module.

If the version of the spinn3r API has changed, you can specify it as a parameter. While the module is not guranteed to work with higher versions of the Spinn3r API than it is designed for, it might if the underlying formats and encodings have not changed.

<B>wantB> This parameter defines the type of item returned by the next() call. WWW::Spinn3r uses XML::Twig to parse the XML returned by Spinn3r and comes with three Twig parsers, WWW::Spinn3r::item, WWW::Spinn3r::link and WWW::Spinn3r::next_request_url. The default value for want is item, which corresponds to the WWW::Spinn3r::item module and returns all fields for an item included in the Spinn3r feed.

The motivation for having multiple parsers is speed. If you only want certain fields from the feed, for example the link and title, it is significantly faster to write a parser that just extracts those two fields from the feed with XML::Twig.

<B>debugB> Emits debug noise on STDOUT if set to 1.
<B>retriesB> The number of HTTP retries in case of a 5xx failure from the API. The default is 5.

<B>B>next()<B>B>

This method returns the next item from the Spinn3r feed. The item is a reference to a hash, which contains the various fields of an item as parsed by the parser specified in the want field of the consutructor (item by default).

The module transparently fetches a new set of results from Spinn3r, using the api:next_request_url returned by Spinn3r with every request, and caches the result to implement next().

You can control the number of results that are fetched with every call by changing the limit parameter at new().

<B>B>last_url()<B>B>

The last API URL that was fetched.

<B>B>mirror()<B>B>

WWW::Spinn3r supports mirroring of the Spinn3r feed to local files and then recreating WWW:Spinn3r objects from these files. This is useful if you want to distribute processing of the feeds over multiple processes or computers.

To mirror feeds to disk, use the alternative constructor <B>mirrorB>, which takes all the same arguments as <B>newB> plus the path argument, which specifies where the files should saved.



    my $m = mirror WWW::Spinn3r ( path => $mirror_dir, ... )
    $m->next_mirror();



The iteration is done with <B>B>next_mirror()<B>B> method, which stores the next feed to a new file, whose filename is derived from the API url.

WWW::Spinn3r objects can be created from these disk files when new() is called with the from_file key:



    my $m = new WWW::Spinn3r ( from_file => ... );



DATE STRING FORMAT

Spinn3r supports ISO 8601 timestamps in the after parameter. To create ISO 8601 timestamps, use the DateTime module that returns ISO 8601 date strings by default. eg:



 after => DateTime->now()->subtract(hours => 48),
 after => DateTime->now()->subtract(days => 31),



REPORTING BUGS

Bugs should be reported at http://rt.cpan.org

SEE ALSO

WWW::Spinn3r::Synced

AUTHOR

Vipul Ved Prakash <vipul@slaant.com>

LICENSE

This software is distributed under the same terms as perl itself.
Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 WWW::SPINN3R (3) 2009-02-14

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.