Google Place API-如何检索开放时间[英] Google Place API - How to retrieve opening hours

本文是小编为大家收集整理的关于Google Place API-如何检索开放时间的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

有一种方法可以获取Google Place的开放时间吗? 我在几个论坛和文档中寻找,但我什么也没发现(也许只有foursquare api揭示了这些信息)

Google不会公开此信息?

是否有任何服务? (Facebook Place,Yelp,ECC ..)

非常感谢所有答复

alberto

推荐答案

我猜现在是可能的:

https://developers.google.com/places/documentation/documentation/detetails#placeetetetailsersresults p>

请参阅如果您不想制作自己的位置API键或安装节点,则此要素用于示例输出.

var request = require('request');
// $ npm install request
// Test code to demonstrate parsing operating hours from Google Places
// https://developers.google.com/places/documentation/details#PlaceDetailsResults

// most establishments specify one set of hours per day:
var testRef = 'CnRoAAAAhWUhxi1GkTSCMDMb2piX2JgQzcMv1v6Bv1rDWAINnWrI6T_Vkn3KRpnI5rTd2NI2f0zy4R8n6vRDoj-qTewKa3r70riORCUF-HNU1FLtI3MHNSw8z0_6fBni6hTuXCsGw1SD44I85ha9GVZOZlAS_hIQuNBJmgTHh9bCC4XvdLiDCBoUfmY1ozj0FW-TvurbmryBdwAvoPo';

// 24 hour restaurants only have one period with open:0000 and no close
var _24hrRef = 'CnRpAAAAcKNSNO0jxSONMAPx7EjG6BdgqhWbzDh1rOWM8I1HJZikRYPxW4L1A1ZwH4HEEBy5diKyXT1nRs2a7cxZK7S4oOr5HrTKewV_WGYdy-CuumuwLzSeckgXWvRdIRCW49JXUeJsqhkhtATHyyIDUYWW4RIQ38ZaUuG8A3WbRrsHLwmwDRoUfmtzSsfki7v8iBmUAZgrUIoVOt0'

// Restaurants that are closed on some days will have fewer than 7 open:close pairs

getPlaceDetails(_24hrRef, function(err, result){
  if(err){ 
    return console.log('Request error: '+err+result);
  };
  console.log('Request successful:')
  console.log(JSON.stringify(result.opening_hours, null, 2));
});

function getPlaceDetails(ref,callback){
  var config = {   
    uri:'https://maps.googleapis.com/maps/api/place/details/json',
    qs: {
      key: "SOME-VALID-GOOGLEPLACES-API-KEY",
      // Generate a new Simple API key and plug it in
      // https://code.google.com/apis/console
      reference:ref,
      sensor:'false',
    }
  };
  request(config, function(err, response, body){
    if(err){ return callback(err) };
    var res = JSON.parse(body);
    switch(res.status){
      case "OK":           return callback(null, res.result);
      case "ZERO_RESULTS": return callback(null, res.result);
      default:             return callback(res.status, body);
    };
  });
};

其他推荐答案

事实API也公开了数小时的操作.这是在API餐厅中,该餐厅由美国80万餐厅组成.该领域的结构为JSON哈希,其中一周的每一天都由整数CF索引. ISO-8601:1 =星期一至7 =星期日.

docs- /places+api+ - +餐厅

餐厅数据演示 - http://www.factual.com/data/data/tata//restaurants-us

餐厅实体的示例.

24: 24,
open_24hrs: false,
accessible_wheelchair: true,
address: "3274 21st St",
alcohol: false,
alcohol_bar: false,
alcohol_beer_wine: false,
alcohol_byob: false,
attire: "casual",
category: "Food & Beverage > Restaurants > Pizza",
country: "US",
cuisine: "Pizza, Italian, American, Fast Food, Pasta",
factual_id: "5873129b-11e9-49db-a012-967b4046420d",
fax: "(415) 695-1687",
founded: "1999",
groups_goodfor: false,
hours: "{"1":[["11:00","24:00"]],"2":[["11:00","24:00"]],"3":[["11:00","24:00"]],"4":[["11:00","24:00"]],"5":[["11:00","1:00"]],"6":[["11:00","1:00"]],"7":[["11:00","24:00"]]}",
kids_goodfor: true,
latitude: 37.75694,
locality: "San Francisco",
longitude: -122.42052,
meal_cater: true,
meal_deliver: true,
meal_dinner: true,
meal_lunch: true,
meal_takeout: true,
name: "Serrano's Pizza and Pasta",
options_vegan: true,
options_vegetarian: true,
owner: "Serranos Pizza",
parking: true,
payment_cashonly: false,
postcode: "94110",
price: 2,
rating: 4.5,
region: "CA",
reservations: false,
seating_outdoor: true,
smoking: false,
status: "1",
tel: "(415) 695-1615",
website: "http://www.serranospizza.com/"

其他推荐答案

它们通过Facebook API暴露.例如,纽约市的粮农组织Schwartz填充了他们的时间:

访问图形API Explorer https://developers.facebook.com/tools.com/tools/explorer 并在框中输入ID:155199767827259

我很确定Yelp API也会公开此信息,但是您必须明确地归因于任何Yelp信息.

本文地址:https://www.itbaoku.cn/post/2090871.html

问题描述

There a way to get the opening hours of google place? I looked for in a several forum and documentations but i didn't find nothing (perhaps only foursquare API expose that information)

Google doesn't expose this information?

Is there any service that expose this? (facebook place, yelp, ecc..)

Thanks so much for all reply

Alberto

推荐答案

I guess this is possible now:

https://developers.google.com/places/documentation/details#PlaceDetailsResults

See this gist for sample output if you don't want to make your own Places API key or install node.

var request = require('request');
// $ npm install request
// Test code to demonstrate parsing operating hours from Google Places
// https://developers.google.com/places/documentation/details#PlaceDetailsResults

// most establishments specify one set of hours per day:
var testRef = 'CnRoAAAAhWUhxi1GkTSCMDMb2piX2JgQzcMv1v6Bv1rDWAINnWrI6T_Vkn3KRpnI5rTd2NI2f0zy4R8n6vRDoj-qTewKa3r70riORCUF-HNU1FLtI3MHNSw8z0_6fBni6hTuXCsGw1SD44I85ha9GVZOZlAS_hIQuNBJmgTHh9bCC4XvdLiDCBoUfmY1ozj0FW-TvurbmryBdwAvoPo';

// 24 hour restaurants only have one period with open:0000 and no close
var _24hrRef = 'CnRpAAAAcKNSNO0jxSONMAPx7EjG6BdgqhWbzDh1rOWM8I1HJZikRYPxW4L1A1ZwH4HEEBy5diKyXT1nRs2a7cxZK7S4oOr5HrTKewV_WGYdy-CuumuwLzSeckgXWvRdIRCW49JXUeJsqhkhtATHyyIDUYWW4RIQ38ZaUuG8A3WbRrsHLwmwDRoUfmtzSsfki7v8iBmUAZgrUIoVOt0'

// Restaurants that are closed on some days will have fewer than 7 open:close pairs

getPlaceDetails(_24hrRef, function(err, result){
  if(err){ 
    return console.log('Request error: '+err+result);
  };
  console.log('Request successful:')
  console.log(JSON.stringify(result.opening_hours, null, 2));
});

function getPlaceDetails(ref,callback){
  var config = {   
    uri:'https://maps.googleapis.com/maps/api/place/details/json',
    qs: {
      key: "SOME-VALID-GOOGLEPLACES-API-KEY",
      // Generate a new Simple API key and plug it in
      // https://code.google.com/apis/console
      reference:ref,
      sensor:'false',
    }
  };
  request(config, function(err, response, body){
    if(err){ return callback(err) };
    var res = JSON.parse(body);
    switch(res.status){
      case "OK":           return callback(null, res.result);
      case "ZERO_RESULTS": return callback(null, res.result);
      default:             return callback(res.status, body);
    };
  });
};

其他推荐答案

The Factual API exposes hours of operation as well. This is in the Restaurant API, which consists of 800k restaurants in the US. The field is structured as a JSON hash where each day of the week is indexed by an integer cf. ISO-8601: 1 = Monday through 7 = Sunday.

Docs - http://developer.factual.com/display/docs/Places+API+-+Restaurants

Demo of restaurant data - http://www.factual.com/data/t/restaurants-us

Example of a restaurant entity.

24: 24,
open_24hrs: false,
accessible_wheelchair: true,
address: "3274 21st St",
alcohol: false,
alcohol_bar: false,
alcohol_beer_wine: false,
alcohol_byob: false,
attire: "casual",
category: "Food & Beverage > Restaurants > Pizza",
country: "US",
cuisine: "Pizza, Italian, American, Fast Food, Pasta",
factual_id: "5873129b-11e9-49db-a012-967b4046420d",
fax: "(415) 695-1687",
founded: "1999",
groups_goodfor: false,
hours: "{"1":[["11:00","24:00"]],"2":[["11:00","24:00"]],"3":[["11:00","24:00"]],"4":[["11:00","24:00"]],"5":[["11:00","1:00"]],"6":[["11:00","1:00"]],"7":[["11:00","24:00"]]}",
kids_goodfor: true,
latitude: 37.75694,
locality: "San Francisco",
longitude: -122.42052,
meal_cater: true,
meal_deliver: true,
meal_dinner: true,
meal_lunch: true,
meal_takeout: true,
name: "Serrano's Pizza and Pasta",
options_vegan: true,
options_vegetarian: true,
owner: "Serranos Pizza",
parking: true,
payment_cashonly: false,
postcode: "94110",
price: 2,
rating: 4.5,
region: "CA",
reservations: false,
seating_outdoor: true,
smoking: false,
status: "1",
tel: "(415) 695-1615",
website: "http://www.serranospizza.com/"

其他推荐答案

They are exposed through the Facebook API. For example, FAO Schwartz in NYC has populated their hours:

Visit the Graph API Explorer https://developers.facebook.com/tools/explorer and type their ID in the box: 155199767827259

I'm pretty sure the Yelp API also exposes this information, but you've got to attribute any Yelp information pretty explicitly.