[TYPO3-dev] REST api
g4-lisz at tonarchiv.ch
g4-lisz at tonarchiv.ch
Tue Apr 29 17:39:12 CEST 2014
Hi Albert,
I wrote this for a client, so it's quite specific and shering is not a
good idea...
But it's really easy to do. The whole trickery is done by realURL:
My REST path looks like this: [hostname]/API/[controller]/[action]/[uid]
e.g. [hostname]/API/shoes/get/34
or [hostname]/API/shoes/list
The action controller returns the JSON encoded obejct(s).
But in my case it is "read only", i.e. i didn't implement any PUT
functionallity.
For the page "API" you should disable any headers in TS. My setup looks
like this:
json = PAGE
json {
config {
disableAllHeaderCode = 1
disablePrefixComment = 1
additionalHeaders = Content-type:application/json
xhtml_cleaning = 0
admPanel = 0
debug = 0
no_cache = 1
}
10 = TEXT
10 < styles.content.get
}
tt_content.stdWrap.innerWrap >
Like this you need to put the plugin as a content element.
If you don't need any cOject functionallity, you could also write the
API as e eID module - but then, realURL would not work. So you had to
write your own URL parsing.
My realurl.conf looks like this:
'fixedPostVars' => array(
'api' => array (
array(
'GETvar' => 'tx_stdapp_api[identifier]',
),
array(
'GETvar' => 'tx_stdapp_api[type]',
),
array(
'GETvar' => 'L',
'valueMap' => array(
'de' => '0',
'it' => '2',
'fr' => '1',
'en' => '4',
),
'optional' => TRUE,
),
array(
'GETvar' => 'tx_stdapp_api[uid]',
'optional' => TRUE,
),
),
(I use only one domain object, which has the properties identifier and
type. So it's actually [hostname]/API/[indetifier]/[type]/[uid]. Without
uid, it returns the whole list.
It should be easy to extend this using different controllers and actions.)
Hope that helps,
Till
On 04/28/2014 10:55 AM, Albert van der Veen wrote:
> Hi Till,
>
> Would you like to share this code, or is it for personal use only? :)
>
> Best,
> Albert
>
> On 19-4-2014 0:49, g4-lisz at tonarchiv.ch wrote:
>> On 04/18/2014 10:43 AM, Albert van der Veen wrote:
>>> Hi all,
>>>
>>> From time to time I've seen posts regarding the implementation of a
>>> REST API for Typo3. Is anyone working on that at the moment? It seems
>>> there have been attempts, from what I've read and searching the TER,
>>> but nothing really matured. Is that correct?
>>> Thanks for any light you can shed on this :)
>>>
>> Hi Albert,
>>
>> I wrote my own extension for talking to mobile apps... a very simple
>> implementation. Combined with realURL, it's a kind of REST API.
>>
>> Cheers,
>> Till
>>
>
> _______________________________________________
> TYPO3-dev mailing list
> TYPO3-dev at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-dev
More information about the TYPO3-dev
mailing list