如何从我的服务器获取 Google 上特定酒店的用户评分?

问题描述 投票:0回答:1

我想定期获取 Google 对 1000 多家酒店的用户评分。我如何从我的服务器执行此操作?是否有任何 API 和任何其他方式可以检索此数据。以及如何做呢?我将非常感激。

我找不到任何相关信息。

google-reviews
1个回答
1
投票

我用以下代码做到了:

$ch = curl_init();

$params = json_encode(["textQuery" => "hotels in Alexandroupolis",]);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_URL, 'https://places.googleapis.com/v1/places:searchText');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);

curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: ' . 'application/json',
    'X-Goog-Api-Key: ' . MyGoogleApiKey,
    'X-Goog-FieldMask: ' . 'places.displayName,places.rating',
]);

$response = curl_exec($ch);
curl_close($ch);

The result of code

© www.soinside.com 2019 - 2024. All rights reserved.