Hello,
when trying to use Net::Google::WebmasterTools I am getting the following error:
https://www.googleapis.com/webmasters/v3/sites/https://www.mySite.com/
+searchAnalytics/query
GWMT error: 404 Not Found Not Found at ./Google_Search_Console_API.pl
+line 43, <DATA> line 2231.
Here the used script (the credentials in this example like $client_id, $client_secret and $refresh_token have been certainly substituted by my own credentials).
#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper;
use Net::Google::WebmasterTools;
use Net::Google::WebmasterTools::OAuth2;
# Insert your website URL here.
my $site_url = "https://www.mySite.com";
# See GETTING STARTED for how to get a client id, client secret, and
# refresh token
my $client_id = "123456789012.apps.googleusercontent.com";
my $client_secret = "rAnDoMsEcReTrAnDoMsEcReT";
my $refresh_token = "RaNdOmSeCrEtRaNdOmSeCrEt";
my $wmt = Net::Google::WebmasterTools->new;
# Authenticate
my $oauth = Net::Google::WebmasterTools::OAuth2->new(
client_id => $client_id,
client_secret => $client_secret,
);
my $token = $oauth->refresh_access_token($refresh_token);
$wmt->token($token);
# Build request
my $req = $wmt->new_request(
site_url => "$site_url",
report_name => "searchAnalytics",
method => "query",
dimensions => ['country','device'],
search_type => 'web',
start_date => "2016-07-01",
end_date => "2016-07-20",
row_limit => 1000,
);
# Send request
my $res = $wmt->retrieve($req);
die("GWMT error: " . $res->error_message) if !$res->is_success;
# Print results
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";
Any ideas what might be wrong?
Best regards,
Frosch