#!/usr/bin/perl
my
$client
= Google::API::Client->new;
my
$service
=
$client
->build(
'adsense'
,
'v1.3'
);
my
$file
=
"$FindBin::Bin/../client_secrets.json"
;
my
$auth_driver
= Google::API::OAuth2::Client->new_from_client_secrets(
$file
,
$service
->{auth_doc});
my
$dat_file
=
"$FindBin::Bin/token.dat"
;
my
$access_token
= get_or_restore_token(
$dat_file
,
$auth_driver
);
my
$res
=
$service
->adclients->list(
body
=> {
maxResults
=> MAX_PAGE_SIZE
})->execute({
auth_driver
=>
$auth_driver
});
for
my
$ad_client
(@{
$res
->{items}}) {
my
$ad_units
=
$service
->adunits->list(
body
=> {
adClientId
=>
$ad_client
->{id},
maxResults
=> MAX_PAGE_SIZE
})->execute({
auth_driver
=>
$auth_driver
});
for
my
$ad_unit
(@{
$ad_units
->{items}}) {
say
"Ad unit with code $ad_unit->{code}, name $ad_unit->{name} and status $ad_unit->{status} was found"
;
}
}
store_token(
$dat_file
,
$auth_driver
);
say
'Done'
;