Search code examples
phpgoogle-search-consolegoogle-api-webmasters

How to get query details FROM webmasters tools api


the new api webmasters tools is not mentioned how to get the details of queries.

Here is my code to get the queries, but I dont know how to get for each query the details :

$client->setAccessToken("XXXXXX--TOKEN--XXXXX");
$webmastersService = new Google_Service_Webmasters($client);
$searchanalytics = $webmastersService->searchanalytics;
$request = new Google_Service_Webmasters_SearchAnalyticsQueryRequest;
$request->setStartDate($date);
$request->setEndDate($date);
$request->setDimensions(array('query'));
$request->setSearchType("web");
$qsearch = $searchanalytics->query($site, $request);
$rows = $qsearch->getRows();

Solution

  • Try to

    var_dump($rows);
    

    and you'll get the idea.