This manual is being depreciated. Much of the information here is out of date.

The new Jomres Documentation, updated in 2022, can be found at Jomres.net/documentation.

Using the REST API in your own software

Do you want to access the Jomres functionality through a simple, well documented API? You can, easily, using the REST API.

 

The API is well documented here, and it provides you with a sigificant amount of flexibility to manipulate the system, but did you know that you can also access the API from within the same server?

 

Let's say that you're building a feature for your client, it's in another component/plugin on the same server. You want to access some Jomres data without making any changes to Jomres Core files. Here's how you do it.

 

/** Create definitions */
if (!defined('_JOMRES_INITCHECK')) { define('_JOMRES_INITCHECK', 1 ); }

if (!defined('JOMRES_ROOT_DIRECTORY')) { define ( 'JOMRES_ROOT_DIRECTORY' , "jomres" ) ; }

/** Include the Jomres Framework */
require_once(JOMRES_ROOT_DIRECTORY.DIRECTORY_SEPARATOR.'core-plugins'.DIRECTORY_SEPARATOR.'alternative_init'.DIRECTORY_SEPARATOR.'alt_init.php');

/** Import the Jomres Call API class */

jr_import('jomres_call_api');
$call_api = new jomres_call_api('system');

/** Set the request method to GET and the endpoint to search for properties with 3 stars ( https://api.jomres.net/?version=latest#548b91ff-549b-4e10-a2ae-2e6674f40b15 ) */

$method = 'GET';
$endpoint = 'search/stars/3';
$result = $call_api->send_request( $method , $endpoint );
var_dump($result);exit;

 

The "system" user is a special REST API user that allows the system to call any installed REST API feature, see

https://github.com/WoollyinWalesIT/jomres/blob/master/libraries/jomres/classes/jomres_call_api.class.php#L109

If you need to send headers, you can do something like

$headers = array ( "X-JOMRES-channel-name : ".$channel_name );

And to POST data you could do something like

$post_data = array ("params" => json_encode($data_object) );

to build the POST data.


When you inspect (or dump) the content of the result you will see something like :

object(stdClass)#4112 (2) {
  ["data"]=>
  object(stdClass)#4111 (1) {
    ["search_results"]=>
    object(stdClass)#4078 (14) {
      ["3"]=>
      object(stdClass)#4073 (15) {
        ["property_name"]=>
        string(13) "Jaguar S Type"
        ["property_street"]=>
        string(16) "26 Goldhawk Road"
        ["property_town"]=>