phpgoogle-cloud-platformgoogle-apigoogle-postmaster

Google PostMaster Service with PHP


I am new to Google Sevices.I am trying to setup and use Gmail Postmaster Tools API

https://developers.google.com/gmail/postmaster/reference/rest

I am able to use it with PostMan but I want use it with PHP. So I have setup client and using something like this

$service = new \Google\Service\PostmasterTools($client);
$results = $service->domains->listDomains();

Its working fine and providing me domain list. but I do not have idea how I can get trafficStats for the domain

https://developers.google.com/gmail/postmaster/reference/rest/v1/domains.trafficStats/get

I have searched lot but not found any tutorial or example related PostMaster tool in PHP.

Let me know if any expert here can help me for the same.

Thanks!


Solution

  • Just randomly came across this and see it's unanswered -- you probably figured it out by now but you could iterate over $results and call listDomainsTrafficStats()

    ex)

    foreach($results->domains as $domain){
      $stats = $service->domains_trafficStats->listDomainsTrafficStats($domain->name);
    }