Hardware Reference
In-Depth Information
Here's the index.php
file. It takes the $_
REQUEST_URI variable and splits it up
into an array of strings, using the slash
(/) as the points on which to split.
Read It
<?php
/*
RESTful reader
Context: PHP
*/
// split the URI string into a list:
$parameters = explode("/", $_SERVER['REQUEST_URI']);
Once you've saved this to the server,
try entering the following URL in a
browser:
// print out each of the elements of the list:
foreach($parameters as $item) {
http://www.myserver.com/myservice/
this/is/a/list/of/restful/parameters/
echo "Item: ";
echo $item."<br>";
}
?>
You should get a response in the
browser like this:
Item:
Item: myservice
Item: this
Item: is
Item: a
Item: list
Item: of
Item: restful
Item: parameters
Now that you've got anything that comes in from the client
in an array, you can do whatever you want with it. This is
where things get interesting. From here, you can write a
program to look for and act on different elements in the
list. The following is a brief example that would pull out
the distance and time parameters based on the runners'
website example above.
 
Search WWH ::




Custom Search