-1

I can't seem to get the opening hours by using google places api.

I used google maps to find a business with hours and rating. I chose a mcdonalds.

enter image description here

I then used google's tool to search the place_id of the address.

Which gets me the place_id:

ChIJRRNEbiK0xokRxwlEbC1WEqk

enter image description here

Then I try to search for the place details using the place_id

https://maps.googleapis.com/maps/api/place/details/json?place_id=ChIJRRNEbiK0xokRxwlEbC1WEqk&fields=name,rating,opening_hours&key=MY_KEY

but I only get the name, which is set as the address.

enter image description here

[edit]@geocodezip said that adding 'Mcdonald's' to the beginning of the address returns a different place_id.

Am I doing something wrong?

Sunwoo Yang
  • 1,213
  • 2
  • 12
  • 22
  • That is likely the place id for the address, not the business. Where did you get the place id from? BTW, pictures of information are not very useful, they can't be copied and pasted for testing. – geocodezip Dec 29 '19 at 23:38
  • If I enter "McDonald's, 2801 Cottman Avenue, Philadelphia, PA, USA" into [the tool](https://developers.google.com/places/place-id), the place id I get is: "ChIJLZZdbiK0xokRqpqP6w3DRiM" – geocodezip Dec 29 '19 at 23:40
  • @geocodezip Sorry for that. I'll update it. – Sunwoo Yang Dec 29 '19 at 23:43

1 Answers1

1

That is the place id for the address, not the business.

If I enter "McDonald's, 2801 Cottman Avenue, Philadelphia, PA, USA" into the tool, the place id I get is: "ChIJLZZdbiK0xokRqpqP6w3DRiM"

If I use that id in your query (with a valid key), I get a response with the extra data:

{
   "html_attributions" : [],
   "result" : {
      "name" : "McDonald's",
      "opening_hours" : {
         "open_now" : true,
         "periods" : [
            {
               "open" : {
                  "day" : 0,
                  "time" : "0000"
               }
            }
         ],
         "weekday_text" : [
            "Monday: Open 24 hours",
            "Tuesday: Open 24 hours",
            "Wednesday: Open 24 hours",
            "Thursday: Open 24 hours",
            "Friday: Open 24 hours",
            "Saturday: Open 24 hours",
            "Sunday: Open 24 hours"
         ]
      },
      "rating" : 3.1
   },
   "status" : "OK"
}

proof of concept fiddle (uses the javascript API places library)

screenshot of fiddle

geocodezip
  • 158,664
  • 13
  • 220
  • 245