geeksareforlife / thoughts

0 stars 0 forks source link

National Trust API #1

Open geeksareforlife opened 6 years ago

geeksareforlife commented 6 years ago

Reverse engineered from the map page.

Place JSON seems to be: https://www.nationaltrust.org.uk/search/data/all-places

They also use the opening times calendar:

https://www.nationaltrust.org.uk/place-pages/1/pages/opening-times-calendar

where 1 is the place id

geeksareforlife commented 6 years ago

There is also land data on data.gov.uk

ghost commented 5 years ago

Thanks for the URL! :-) However I keep getting;

Access to XMLHttpRequest at 'https://www.nationaltrust.org.uk/search/data/all-places' from origin 'http://localhost:7894' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

Any way around it?

geeksareforlife commented 5 years ago

Hmm, I haven't actually used it in anything yet, but it looks like a Cross-Origin issue. I would normally be using this in a PHP script, so wouldn't have that issue, but you can solve it in Javascript by using a CORS proxy, such as https://github.com/Rob--W/cors-anywhere

An example of this would be: https://jsfiddle.net/geeksareforlife/c5jhogps/2/

But you need to be careful using CORS proxies in any production code - make sure you understand what and why you are using them!

ghost commented 5 years ago

Hiya @geeksareforlife thanks for the reply and apologies for my late reply. What would recommend for PHP script? do you have any tutorials you can point me too please?

geeksareforlife commented 5 years ago

I would normally write a script fresh for each thing I am doing, so I don't really have a recommendation for that.

There are plenty of free resources for PHP tutorials, just make sure that they are based on PHP7 and above. Also, remember that you will need a server to run PHP scripts.