About SIMPLX_RPC
AJAX made really simple
SIMPLX RPC is a remote method invocation Snippet. It makes it possible to call the MODx API from the client browser using XMLHTTP, or, from another app. This means that you can, as an example, read and update data from MODx without reloading the page. This in turn means more interactive, dynamic, responsive, personal web sites :)
This Snippet simply wraps the MODx API (http://wiki.modxcms.com/index.php/Ja:API:DocumentParser) with the JSON-RPC protocol (http://groups.google.com/group/json-rpc/web/json-rpc-1-2-proposal). It should match the documented API spot on i think.
Screencast
http://www.youtube.com/watch?v=B3BWLg87zyE
JSON RPC 2.0 Compliant
As of version 0.6.1 SIMPLX RPC is fully compliant with the JSON RPC standard. JSON RPC is a port of the popular XML RPC standard which is used as a service layer by many systems on the market today. If you want to integrate MODx using XML RPC i can recommend a PHP script which handle conversion between the two, http://code.google.com/p/json-xml-rpc/
Note
Note that this implementation uses named parameters. This means that the parameters collection must be represented as a JavaScript object with key/value pairs. This ensures that parameter sequence is not an issue when calling in method calls.
SIMPLX RPC will in the near future remove all MODx API methods which have been marked as "deprecated" by the MODx team. Please use Snippet matching and wrap your own "procedures" in Snippets. This is good design as it abstracts code into logical components; it also offers maximum security options using ACL's etc.
Have Fun :)
Information
Released
September 12, 2011
Supported Database
MySQL, SQL Server
License
GPLv3
Supported Versions
2.0 - <2.0
Downloads
4,445
Instructions
To get the Snippet working please,
- create one page which uses the SIMPLX RPC template. This is the page which will act as a access point for all RPC calls. Remember to set appropriate access permissions for this page.
- create another page using the SIMPLX RPC EXAMPLE template. This example template has some really nice sample/debug features!
- Test out the SIMPLX_RPC_EXAMPLE Snippet which shows you how to query getResources.
The Examples Console
The console on the example page is really cool :D
It lets you make test calls to your site and try out templating etc.
- The "Query Config" tab shows the current json config object. To start using your ModX site to get actual "live" data, just set the params to match your setup (url, pageid which uses the SIMPLX_RPC template, Snippet name and parameters).On my site my live test-example Query looking like this: {"host":"http://mywebaddress.com/modx/","service":"?id=2","rpc":{"jsonrpc":"2.0","id":"1","method":"simplx_rpc_example","params":{"parents":"0"}}}
- The "Template" tab contains the jQuery Template html code. This can be updated and viewed "live".
- The "JSON Result" tab shows the current response from the server.
New in 0.6.6-pl1
Added more compliance to json-rpc 2.0 by always setting response Content-Type to "application/json".
Updated the client side script with better parameter naming etc. This is the new look:
{ "host":"http://myhostname.com/", "service":"?id=2", "rpc":{ "jsonrpc":"2.0", "id":"1", "method":"simplx_rpc_example", "params":{ "parents":"0" } } }
Note that the previous
- "url" and
- "pageid"
- "host" and
- "service"
Reminder, I have removed all deprecated API methods