Knowledgeroot REST API (concept)
Table of Contents
Implementation
Using Zend_Rest with JSON.
All magic is done by rest.php in knowledgeroot root folder.
Modrewrite is required to send all url stuff that started with rest is send to rest.php .
HTTP Methods
- POST/PUT - reading/modify data
- DELETE - delete data
URL Examples
Content URLs
read
allowed HTTP methods: POST/PUT
rest/content/333
new/edit
allowed HTTP methods: POST/PUT
rest/content/new rest/content/333
delete
allowed HTTP methods: POST/PUT/DELETE
rest/content/333
list
allowed HTTP methods: POST/PUT
rest/content/list/all rest/content/list/4711 (pageid)
move
rest/content/4711/move
Page URLs
rest/page/123/content/new rest/page/123/content/563 rest/page/new rest/page/123 rest/page/list/all rest/page/list/4711
move
rest/page/4712/move
File URLs
rest/file/new rest/file/4711 (fileid for delete) rest/file/list/all rest/file/list/4711 (contentid)
Search URLs
rest/search
User URLs
rest/user
Group URLs
rest/group
JSON Requests
Request Structure
{
"head":
{
"auth":
{
"apikey": "XYZ"
},
"action": ""
},
"body":
{
}
}
Content Read
{
"head":
{
"auth":
{
"apikey": "XYZ"
},
"action": "read"
},
"body":
{
}
}
Content New/Edit?
{
"head":
{
"auth":
{
"apikey": "XYZ"
},
"action": "new|edit"
},
"body":
{
"title": "test",
"content": "this is your content",
"belongsto": 33,
"type": "text",
"sorting": 99,
"owner": 4711,
"group": 4712,
"userrights": 2,
"grouprights": 2,
"otherrights": 2,
"modifymultiplerights": "true",
"multiplerights":
[
{
"type": "user",
"userid": 4713,
"right": 2
},
{
"type": "user",
"userid": 4714,
"right": 1
},
{
"type": "group",
"groupid": 4717,
"right": 2
}
]
}
}
Content Delete
{
"head":
{
"auth":
{
"apikey": "XYZ"
},
"action": "delete"
},
"body":
{
}
}
Content List
Content Move
{
"head":
{
"auth":
{
"apikey": "XYZ"
},
"action": "move"
},
"body":
{
}
}
JSON Response
Response structure
{
"head":
{
"error": false,
"error_message": "",
"error_code": ""
},
"body":
{
}
}
Content
New/Edit/Read? Response
{
"head":
{
"error": false,
"error_message": "",
"error_code": ""
},
"body":
{
"id": 123,
"title": "test",
"content": "this is your content",
"belongsto": 33,
"type": "text",
"sorting": 99,
"owner": 4711,
"group": 4712,
"userrights": 2,
"grouprights": 2,
"otherrights": 2,
"multiplerights":
[
{
"type": "user",
"userid": 4713,
"right": 2
},
{
"type": "user",
"userid": 4714,
"right": 1
},
{
"type": "group",
"groupid": 4717,
"right": 2
}
],
"lastupdatedby": 4713,
"lastupdated": "2011-05-13 23:54:53",
"createdate": "2011-05-11 22:21:11"
}
}
