Version 11 (modified by Fran Boon, 13 years ago) ( diff )


REST Interface

Resources are accessible via RESTful URIs to allow the creation of Mash-ups:

JSON uploads should be PUT to http://server.domain/eden/module/resource.json

NB JSON must not include trailing commas in lists (just like Internet Explorer). [This is a SimpleJSON limitation]




For testing/PUT using CURL follow the example

In the example - represents your login and password is to be replaced by your password.

person.xml is the file name to PUT

curl -H 'content-type:application/xml' -T person.xml

WordPress integration

Courtesy of timClicks. This example is for HumanityRoad's WordPress to pull in Hospitals data from Sahana Eden:

$download_error = False;
$hospital_source_file = '';

$hospital_table_format = <<<HOSPITAL_TABLE_ROWS
	<tr class="hospital-info">
			<h4><a href="%s">%s</a></h4>
			<p>%s<br />%s</p>
			<dl class="hospital-d">
			<dl class="hospital-d">
	<tr class="hospital-comments">
		<td colspan="3">
			<dl class="hospital-d">
	<tr class="hospital-tech-details">
		<td colspan="3">
			<span>Modified by:</span>
			<span>%s</span> | 
			<span>Last Modified</span>
			<span>%s</span> | 
			<span>Global Identifier:</span>
		<td colspan="3"><hr /></td>

$head = <<<HEAD
<!DOCTYPE html><html><head>

td {
	margin: 1em 0;
	padding: 0;

dt {
	position: relative;
	left: 0;
	top: 1.1em;
	width: 5em;
	font-weight: bold;
} dd {
	border-left: 1px solid #000;
	margin: 0 0 0 6em;
	padding: 0 0 .5em .5em;

.hospital-tech-details {


function process_comments($comment_string){
	$a = explode("\r\n", $comment_string);
	foreach($a as &$para){
		$para = $para.'<br />';
	return '<p>'.implode($a).'</p>';

// untested
function check_and_set($item, $assoc_array) {
	if (array_key_exists($item, $assoc_array)) {
		$val = $assoc_array[$item];
	} else {
		$val = '&nbsp;';
	return $val;

function process_hospital_info($hospital) {
	global $hospital_table_format;

	$city = check_and_set('city', $hospital);
	$website = check_and_set('website', $hospital);
	$name = check_and_set('name', $hospital);
	$address = check_and_set('address', $hospital);
	$phone = check_and_set('phone', $hospital);
	$email = check_and_set('email', $hospital);
	$lat = check_and_set('@lat', $hospital['$k_location_id']);
	$lon = check_and_set('@lon', $hospital['$k_location_id']);
	$comments = check_and_set('comments', $hospital);
	$modified_by = check_and_set('@modified_by', $hospital);
	$last_modified = check_and_set('@modified_on', $hospital);
	$uuid = check_and_set('@uuid', $hospital);

	return sprintf($hospital_table_format, $website, $name, $address, $city, $phone, $website, $email, $lat, $lon, $comments, $modified_by, $last_modified, $uuid);

echo $head;
echo '<h3>yo!</h3>';

$hospital_json = file_get_contents($hospital_source_file);
if ($hospital_json === False) {
	$download_error = True;
} else {
	$hospitals = json_decode($hospital_json, True);

foreach ($hospitals['$_hms_hospital'] as &$hospital) {
	$hospital_table[] = process_hospital_info($hospital);
print '<table border="0" style="padding:3px;">';
print implode($hospital_table);
print '</table>';

echo '</body>';


Note: See TracWiki for help on using the wiki.