0

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

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

<?php
require_once ('google-api-php-client-2.2.2/vendor/autoload.php');

$client->setAccessToken("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
$webmastersService = new Google_Service_Webmasters($client);
$searchanalytics = $webmastersService->searchanalytics;


// Build query
$request = new Google_Service_Webmasters_SearchAnalyticsQueryRequest;
$request->setStartDate('startdate');
$request->setEndDate('enddate');
$request->setDimensions("query");
$request->setSearchType("web");
$request->setRowLimit(10);
$qsearch = $searchanalytics->query("siteurl", $request); 
$rows = $qsearch->getRows();

var_dump($rows);
?>

But our code was not working.

what is the issue in our code?

Appreciate any help and ideas. Thanks!

Tushar Korat
  • 591
  • 2
  • 7
  • 21

1 Answers1

0

But our code was not working.

what is the issue in our code?

I am not authorized to post comment under your topic, so I post here on Answer. You should post the detail about "not working".Error messages or logs would be OK.

And should be $targetSites = $webmastersService->sites->listSites()->siteEntry; $qsearch = $searchanalytics->query($targetSite->siteUrl, $request);

I also doubt that 'startdate' and 'enddate', not conclete values, work.

Damegami
  • 37
  • 5