我正在查询Google Search Console API并获取数据但是我无法获取特定的行。
array:20 [▼
0 => Google_Service_Webmasters_UrlCrawlErrorCountsPerType {#301 ▼
#collection_key: "entries"
#internal_gapi_mappings: []
+category: "notFound"
#entriesType: "Google_Service_Webmasters_UrlCrawlErrorCount"
#entriesDataType: "array"
+platform: "web"
#modelData: array:1 [▼
"entries" => array:1 [▼
0 => array:2 [▼
"count" => "64"
"timestamp" => "2016-08-04T20:15:25.816Z"
]
]
]
#processed: []
}
1 => Google_Service_Webmasters_UrlCrawlErrorCountsPerType {#302 ▶}
2 => Google_Service_Webmasters_UrlCrawlErrorCountsPerType {#305 ▶}
3 => Google_Service_Webmasters_UrlCrawlErrorCountsPerType {#306 ▶}
4 => Google_Service_Webmasters_UrlCrawlErrorCountsPerType {#307 ▶}
5 => Google_Service_Webmasters_UrlCrawlErrorCountsPerType {#308 ▶}
6 => Google_Service_Webmasters_UrlCrawlErrorCountsPerType {#309 ▶}
7 => Google_Service_Webmasters_UrlCrawlErrorCountsPerType {#310 ▶}
响应;
{{1}}
我可以获取类别和平台但无法知道如何访问#modelData>条目> 0> count
中的计数答案 0 :(得分:0)
我的客人你的回复类似于Json, 如果是这样,你可以尝试$ responds_decode = json_decode(“string json”,true) 然后它将像数组一样访问对象。
答案 1 :(得分:0)
您可以使用getter和setter检索这样的值:
$response = $webmaster->urlcrawlerrorscounts
->query($url, $options)
->getCountPerTypes();
foreach ($response->getCountPerTypes() as $type) {
$entries = [];
foreach ($type->getEntries() as $entry) {
$count = $entry->getCount();
$timestamp = $entry->getTimestamp();
$entries[] = [$count, $timestamp];
}
$platform = $type->getPlatform();
$category = $type->getCategory();
// Do what you want with it ...
}
这个类有的所有方法: https://api.kdyby.org/class-Google_Service_Webmasters_UrlCrawlErrorCountsPerType.html