|
NAMEWWW::Spinn3r - An interface to the Spinn3r API (http://www.spinn3r.com)SYNOPSISuse 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}; } DESCRIPTIONWWW::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 KEYSpinn3r service is available through a vendor key, which you can get from the good folks at Tailrank, "http://spinn3r.com/contact".HOW TO USEMost 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.new()The contructor. This function takes a hash with the following keys:
next()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()". last_url()The last API URL that was fetched.mirror()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 => ... ); DATE STRING FORMATSpinn3r 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 BUGSBugs should be reported at "http://rt.cpan.org"SEE ALSOWWW::Spinn3r::SyncedAUTHORVipul Ved Prakash <vipul@slaant.com>LICENSEThis software is distributed under the same terms as perl itself.
Visit the GSP FreeBSD Man Page Interface. |