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
WWW::Spinn3r(3) User Contributed Perl Documentation WWW::Spinn3r(3)

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

 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};
 }

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".

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

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.

The contructor. This function takes a hash with the following keys:
api
"permalink3.getDelta" or "feed3.getDelta", one of the two APIs provided by Spinn3r.
params
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 version parameter to the API is a function of version of this module. and the version() 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.

want
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.

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

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()".

The last API URL that was fetched.

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 mirror, which takes all the same arguments as new 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 next_mirror() 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 => ... );

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),

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

WWW::Spinn3r::Synced

Vipul Ved Prakash <vipul@slaant.com>

This software is distributed under the same terms as perl itself.
2009-02-14 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

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