2016-07-26 69 views
0

我没有使用Google搜索控制台API获取结果。同时呼吁其放弃 未捕获的异常 'Google_Exception' 与信息功能“(查询)缺少必需的PARAM: 'SITEURL' SITEURL /测试-AAP/src目录/谷歌/服务/ Resource.php:165Google搜索控制台API - UrlCrawlErrorCountsPerType

$timestamp = strtotime('1 month ago'); 
      $query = new Google_Service_Webmasters_UrlCrawlErrorCountsPerType(); 
      $query->setCategory("authPermissions");  
      $filter = new Google_Service_Webmasters_UrlCrawlErrorCount(); 
      $filter->setCount('5'); 
      $filter->setTimestamp($timestamp); 

      $check = $query->setEntries(array($filter)); 
      $query->setPlatform("web"); 
      $getSearchresponseOb = $service->urlcrawlerrorscounts->query('siteurl','soft404','true','web'); 
      $getSearchresponse  = $getSearchresponseOb->toSimpleObject(); 
      print_r($getSearchresponse); 

回答

0

我认为错误信息很明显。 (如:http://www.example.com/) 根据谷歌的文档https://developers.google.com/webmaster-tools/v3/urlcrawlerrorscounts/query的“SITEURL”应该是一个URL,因此,你应该有这样的事情:

$check = $query->setEntries(array($filter)); 
$query->setPlatform("web"); 
$getSearchresponseOb = $service->urlcrawlerrorscounts->query('**http://www.example.com**','soft404','true','web'); 
$getSearchresponse = $getSearchresponseOb->toSimpleObject(); 
print_r($getSearchresponse);