RESTful Web Service: Where and Why?
A RESTful web service has been created at https://sharedsapience.website/bespoke_php_files/planetary_statistics.php. The purpose of this RESTful web service is to output statistics relating to each of the nine planets in our solar system.

RESTful Web Service: What?
The following planetary statistics are output by this RESTful web service: planet name; distance from the sun (in metres and kilometres); distance from each of the other eight planets (in metres and kilometres); and the time it takes sunlight to travel to the planet.
The statistics can be output in the following formats: html; text; json; and xml.

RESTful Web Service: How?
The planetary statistics have been calculated based on the following assumptions:
-
- The speed of light is: 299,792,458 metres per second
[Source: www.quora.com] - An astronomical unit (au) is: 149,597,870,700 metres [Source: wikipedia.org]
- The distance [measured in astronomical units] of each of the planets from the sun is: Mercury – 0.387 au; Venus – 0.723 au; Earth – 1 au; Mars – 1.52 au; Jupiter – 5.20 au; Saturn – 9.58 au; Uranus – 19.20 au; Neptune – 30.05 au; and Pluto – 39.48 au. [Source: nasa.gov]
- The speed of light is: 299,792,458 metres per second

Communicating with the RESTful web Service
The RESTful Web Service requires two parameters to be passed in the request string: planet and format; both parameters are case-insensitive.
The correct request string syntax can be expressed thusly:
https://sharedsapience.website/bespoke_php_files/planetary_statistics.php?planet=PLANET&format=FORMAT
PLANET can be any of the nine planets in our solar system: Mercury; Venus; Earth; Mars; Jupiter; Saturn; Uranus; Neptune; or Pluto. FORMAT can be any of the following output types: html; text; json; or xml.
If the request string is correctly-formed, the RESTful Web Service responds with a ‘200 OK’ HTTP header and outputs relevant statistics for the desired planet in the specified format. If a malformed request string is received, the RESTful Web Service responds with a ‘400 Bad Request’ HTTP header and outputs a custom error message detailing the expected request string formulation.

