PHP从企业名称获取谷歌地方的详细信息 [英] php get google place details from business name
问题描述
我想从google place ip中提取业务数据.我可以通过在下面的代码中使用place_id来做到这一点;
I want to pull business data from google places ip. I can do that by using place_id with the code below;
$name = urlencode('Business name');
$place_id = 'XXXXXXXXXXXXXXXX';
$url = 'https://maps.googleapis.com/maps/api/place/details/json?placeid='.$place_id.'&key=XXXXXXXXXXXXXXXXX';
$json = file_get_contents($url);
$jsonContent = json_decode($json, TRUE);
$jsonContent['result']['name'];
$jsonContent['result']['formatted_phone_number'];
$jsonContent['result']['formatted_address'];
$jsonContent['result']['website'];
$jsonContent['result']['place_id'];
我想做的是使用公司名称获取公司数据或使用公司名称获取place_id,因此我可以使用上面的代码提取数据.通过以下链接可以获取带有公司名称的地点ID;
What I want to be able to do is the get business data using business name or get place_id by using business name so i can use the code above to pull the data. Obtaining the the place id with business name is possible on the following link;
任何人都可以帮助我如何使用公司名称获取业务数据或如何使用公司名称获取地点ID?
Can anyone help with how i can obtain either business data using business name or obtain place id using business name?
推荐答案
如果您的公司具有唯一的名称,则可以使用网络API .
If your businesses have unique names, you can use web API for that.
$url = 'https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=-33.8670522,151.1957362&radius=5000&name=BestBusiness&key=YOUR_API_KEY';
$json = file_get_contents($url);
$data = json_decode($json);
从 $ data
中获取ID并享受它.
Get id out of $data
and enjoy it.
这篇关于PHP从企业名称获取谷歌地方的详细信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!