Jonathan Leto > Net-Topsy-0.03 > Net::Topsy::Result

Download:
Net-Topsy-0.03.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  1
View/Report Bugs
Source  

NAME ^

Net::Topsy::Result - Topsy Result Objects

SYNOPSIS ^

    use Net::Topsy;

    my $topsy  = Net::Topsy->new( key => $ENV{TOPSY_API_KEY} );
    my $result = $topsy->search({
                                    q => $search_term,
                                    page   =>  1,  # default
                                    perpage => 30, # 30 per page
                                    window => 'd', # today
                                });
    my $iter   = $result->iter;
    while ($iter->has_next) {
        my $item = $iter->next;
        printf "%-60s : %d : %s\n", $item->{title} ,$item->{hits}, $item->{url};
    }

Each API call to a Net::Topsy object returns an object that abstracts away some of the intricacies of the raw data structure that is returned. The result of an API call has some metadata associated with it, as well as an iterator that allows you to access the list of data.

METHODS ^

iter
    my $iter   = $result->iter;
    while ($iter->has_next) {
        my $item = $iter->next;
        ...
    }

Returns an iterator that is a subclass of MooseX::Iterator, which allows access to the list of data that is the result of a Topsy API call.

page
    my $page = $result->page();

Returns the current page number of the results.

window
    my $window = $result->window();

Returns the single letter designation of the time window.

total
    my $total = $result->total();

Returns the total number of results.

perpage
    my $perpage = $result->perpage();

Returns the number of results "per page", i.e. the number of results in the list.

perl
    my $perl = $result->perl();

Returns the perl (hash reference) representation of the JSON that is returned by the Topsy API.

json
    my $json = $result->json();

Returns the raw string of JSON that is returned by the Topsy API.

response
    my $r = $result->response();

Returns the HTTP::Response object that is returned by the Topsy API.

list
    my $list = $result->list();

Returns an array reference of hash references that is the raw representation of what is returned by the Topsy API. You probably shouldn't mess with this, but maybe you know what you are doing.

The structure of this list can change at any time, don't depend on it.

AUTHOR ^

Jonathan Leto, <jonathan at leto.net>

COPYRIGHT & LICENSE ^

Copyright 2009 Jonathan Leto <jonathan@leto.net>, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

syntax highlighting: