Net::Google::WebmasterTools::Response - Google Webmaster Tools API response
version 0.03
my $res = $wmt->retrieve($req); die("GWMT error: " . $res->error_message) if !$res->is_success; print "Results: 1 - ", $res->items_per_page, " of ", $res->total_results, "\n\n"; for my $row (@{ $res->rows }) { print $row->get_source, ": ", $row->get_visits, " visits, ", $row->get_bounces, " bounces\n"; } print "\nTotal: ", $res->totals("visits"), " visits, ", $res->totals("bounces"), " bounces\n";
Response class for Net::Google::WebmasterTools web service.
True for successful requests, false in case of an error.
The HTTP status code.
The HTTP status message.
In case of an error, this field contains a JSON string with additional information about the error from the response body.
The full error message.
The total number of results for the query, regardless of the number of results in the response.
The 1-based start index of the result rows.
The number of rows returned.
Returns true if the results contain sampled data.
A hashref containing information about the analytics profile.
An arrayref of result rows of type Net::Google::WebmasterTools::Row.
An array of all dimension names.
my $total = $res->totals($metric);
Returns the sum of all results for a metric regardless of the actual subset of results returned. $metric is a metric name without the 'ga:' prefix and converted to lower case with underscores.
$res->project(\@proj_dim_names, \&projection);
Projects the dimension values of every result row to new dimension values using subroutine reference \&projection. The metrics of rows that are mapped to the same dimension values are summed up.
Argument \@proj_dim_names is an arrayref containing the names of the new dimensions.
The projection subroutine takes as single argument a Net::Google::WebmasterTools::Row object and must return an array of dimension values.
The following example maps a single dimension of type ga:pagePath to categories.
$res->project([ 'category' ], sub { my $row = shift; my $page_path = $row->get_page_path; return ('flowers') if $page_path =~ m{^/(tulips|roses)}; return ('fruit') if $page_path =~ m{^/(apples|oranges)}; return ('other'); });
Nick Wellnhofer <wellnhofer@aevum.de>
This software is copyright (c) 2012 by Nick Wellnhofer.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Rob Hammond <contact@rjh.am>, Nick Wellnhofer <wellnhofer@aevum.de>
This software is copyright (c) 2015 by Nick Wellnhofer.
To install Net::Google::WebmasterTools, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::Google::WebmasterTools
CPAN shell
perl -MCPAN -e shell install Net::Google::WebmasterTools
For more information on module installation, please visit the detailed CPAN module installation guide.