I have create a page to retrieve Google Postmaster data using API calls on a PHP file. The method works well and I’m getting the data that I want however I have realised that as soon as a subdomain has no data in spam rate for example, the method returns nothing despite the fact that this subdomain ($domainGoogleName) still has IP reputation or domain reputation for that specific day.
// Create Postmaster Tools service
$postmasterService = new PostmasterTools($client);
try{
$trafficStats = $postmasterService->domains_trafficStats->listDomainsTrafficStats($domainGoogleName,
[
"startDate.day" => [intval($startDay)],
"startDate.month" => [intval($startMonth)],
"startDate.year" => [intval($startYear)],
"endDate.day" => [intval($endDay)],
"endDate.month" => [intval($endMonth)],
"endDate.year" => [intval($endYear)],
]);
if (count($trafficStats->getTrafficStats()) === 0) {
echo "NO DATA";
} else {
foreach ($trafficStats->getTrafficStats() as $stat) {
echo $stat->getDomainReputation();
echo $stat->getDkimSuccessRatio();
echo $stat->getUserReportedSpamRatio();
etc
...
}
}
} catch (Exception $e) {
echo $e->getMessage();
}
Would you know why Google doesn’t return anything even-though I know there is data?
Thanks
I have tried to change the date to pull the data, tried to add an if to check if there is value but my algorithm doesn’t even display “NO DATA”