tags:

views:

441

answers:

2

Using my own Joomla 1.5 component, module, or plugin, how would I turn a request for a REST URL like foo.com/api/... into relevant echo()s on the page? I'm looking for a "hello, world"-level example, if possible.

For example, foo.com/api/baskets/10/fruits/list.json might result in something like the following text on the page:

-- resource: baskets [id: 10]
-- resource: fruits [id: -]
-- action: list
-- format: json

Is that possible?

A: 

To my knowledge, there's nothing currently available that does this. However, between the JRequest, JURI, and JDocument classes, you should be able to build a RESTful interface for a component.

jlleblanc
A: 

It sounds like you want to read up on Routing.

Without the SEF options, you would simply link to something like the URL below, then in your controller, you'd check for the parameters:

index.php?option=com_example&baskets=10&action=list&formaat=json

With SEF turned on you can control the appearance of the URLs (aka "slugs) via routing.

DisgruntledGoat