ReST
From Wiki2
ReST
Apache setup
Add rewrite rules
so a restful path /hsc/feeds/1234 (which doesn't really exist) sends you to the API which processes the request using the /feeds/12345 information from the path.
In /etc/apache2/sites-available/default add rules like <syntaxhighlight lang="html5"> <Directory /var/www/hsc> RewriteEngine On RewriteRule feed/([0-9]+) /var/www/hsc/index.php?id=$1 RewriteRule feeds /var/www/hsc/index.php RewriteRule datastreams /var/www/hsc/index.php?id=$1 RewriteRule prog /var/www/hsc/index.php?id=$1 RewriteRule progs /var/www/hsc/index.php?id=$1 </Directory> remember to restart apache /usr/sbin/apache2ctl restart </syntaxhighlight> The API processing code resides in /hsc in this case.
when to GET PUT POST
- GET when you want some data
- PUT when you've got data to put in the API
- POST when you want to setup something new
- DELETE duh
In the case of home_system_control (hsc):
- GET request to /api/users – List all users
- GET request to /api/users/1 – List info for user with ID of 1
- POST request to /api/users – Create a new user
- PUT request to /api/users/1 – Update user with ID of 1
- DELETE request to /api/users/1 – Delete user with ID of 1
refs
- cosm curl helper
- http://api.cosm.com/v2/feeds/83080/datastreams/noise.csv?start=2013-01-11T19:30:00Z&end=2013-01-11T21:00:00Z&interval=0 doesn't work
- http://cosm.github.com/cosm-js/tutorial/
- accessing-incoming-put-data-from-php
- create-a-rest-api-with-php
- http://rest.elkstein.org/2008/02/using-rest-in-php.html
- http://blog.garethj.com/2009/02/17/building-a-restful-web-application-with-php/
- get for my feed
- making-reliable-connections-with-arduino