我无法通过Google搜索控制台API获得结果。同时调用函数未捕获异常"Google_exception",消息"(查询)丢失必需参数:"siteUrl"siteUrl/test-aap/src/Google/Service/Resource.php:165
$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);
我认为错误消息是显而易见的。根据谷歌的文档https://developers.google.com/webmaster-tools/v3/urlcrawlerrorscounts/query"siteURL"应该是一个URL(例如。http://www.example.com/)因此你应该有这样的东西:
$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);