This REST API is a work in progress. It implements access to some entities of OBM database without using the UI interface.
As februar, 2010, only contacts and companies are accessibles.
WARNING
There's no access control, with this API you have access to all items without usual restrictions.
The user used to access the data is the superadmin.
Apache module mod_rewriting installed and active. (tests done with apache 2.2)
OBM 2.0.3 or newer.
The files are located in the contrib/rest directory in obm svn module.
Apache rewrite rules (in OBM virtual host)
RewriteEngine On
RewriteLog "/var/log/apache2/rewrite.log"
RewriteCond %{THE_REQUEST} /rest/([^/]*)/search/([^?\ ]*)
RewriteRule ^.*$ /rest/index.php?entity=%1&action=search&%2 [L]
RewriteRule ^/rest/([^/]*)/values/(.*) /rest/index.php?entity=$1&action=values&field=$2 [L]
RewriteRule ^/rest/([^/]*)(/(.*))?$ /rest/index.php?entity=$1&entity_id=$3 [L]
PHP files
Please put the entire rest directory inside the /path/to/obm/php/ tree.
Copy the config.inc.sample to config.inc and modify the config.inc if necessary.
The URL are :
- for the list
http://www.domain.tld/obm/rest/<entity> ex. : http://www.mydomain.com/obm/rest/contact
- for the detail
http://www.domain.tld/obm/rest/<entity>/<entity_id> ex. : http://www.mydomain.com/obm/rest/contact/2
- for a search
http://www.domain.tld/obm/rest/<entity>/search/<query> ex. : http://www.mydomain.com/obm/rest/contact/search/fname=Roger&town=Paris
- for a multi-parameters search
http://www.domain.tld/obm/rest/<entity>/search/<query> ex. : http://www.mydomain.com/obm/rest/contact/search/firstname=Roger|Robert&town=Paris
- for a multi-parameters search with only some field required
http://www.domain.tld/obm/rest/<entity>/search/<query> ex. : http://www.mydomain.com/obm/rest/contact/search/firstname=Roger|Paul&town=Paris&require_fields=contact_firstname|contact_lastname
- for a list of possible values for some contact field (firstnames, lasnames, zipcodes, towns)
http://www.domain.tld/obm/rest/contact/values/<field> ex. : http://www.mydomain.com/obm/rest/contact/values/firstnames
index.php is the main file. It receives the requests, call the functions and send back the correct http header and xml.
config.inc sets some paths and parameters
contact.php and company.php are similar :