Fix /privatedata/getattribute route
This commit is contained in:
parent
71918a820f
commit
7426217e76
10
lib/api.php
10
lib/api.php
|
@ -38,14 +38,16 @@ class OC_API {
|
||||||
* @param callable $action the function to run
|
* @param callable $action the function to run
|
||||||
* @param string $app the id of the app registering the call
|
* @param string $app the id of the app registering the call
|
||||||
*/
|
*/
|
||||||
public static function register($method, $url, $action, $app){
|
public static function register($method, $url, $action, $app,
|
||||||
|
$defaults = array(),
|
||||||
|
$requirements = array()){
|
||||||
$name = strtolower($method).$url;
|
$name = strtolower($method).$url;
|
||||||
$name = str_replace(array('/', '{', '}'), '_', $name);
|
$name = str_replace(array('/', '{', '}'), '_', $name);
|
||||||
if(!isset(self::$actions[$name])){
|
if(!isset(self::$actions[$name])){
|
||||||
OC::$router->create($name, $url.'.{_format}')
|
OC::$router->create($name, $url.'.{_format}')
|
||||||
->method($method)
|
->method($method)
|
||||||
->defaults(array('_format' => 'xml'))
|
->defaults(array('_format' => 'xml') + $defaults)
|
||||||
->requirements(array('_format' => 'xml|json'))
|
->requirements(array('_format' => 'xml|json') + $requirements)
|
||||||
->action('OC_API', 'call');
|
->action('OC_API', 'call');
|
||||||
self::$actions[$name] = array();
|
self::$actions[$name] = array();
|
||||||
}
|
}
|
||||||
|
@ -112,7 +114,7 @@ class OC_API {
|
||||||
private static function respond($response, $format='json'){
|
private static function respond($response, $format='json'){
|
||||||
if ($format == 'json') {
|
if ($format == 'json') {
|
||||||
echo json_encode($response);
|
echo json_encode($response);
|
||||||
} else if ($format == 'xml') {
|
//} else if ($format == 'xml') {
|
||||||
// TODO array to xml
|
// TODO array to xml
|
||||||
} else {
|
} else {
|
||||||
var_dump($format, $response);
|
var_dump($format, $response);
|
||||||
|
|
|
@ -12,6 +12,8 @@ OC_API::register('post', '/person/check', array('OC_OCS_Person', 'check'), 'ocs'
|
||||||
// Activity
|
// Activity
|
||||||
OC_API::register('get', '/activity', array('OC_OCS_Activity', 'activityGet'), 'ocs');
|
OC_API::register('get', '/activity', array('OC_OCS_Activity', 'activityGet'), 'ocs');
|
||||||
// Privatedata
|
// Privatedata
|
||||||
|
OC_API::register('get', '/privatedata/getattribute', array('OC_OCS_Privatedata', 'get'), 'ocs', array('app' => '', 'key' => ''));
|
||||||
|
OC_API::register('get', '/privatedata/getattribute/{app}', array('OC_OCS_Privatedata', 'get'), 'ocs', array('key' => ''));
|
||||||
OC_API::register('get', '/privatedata/getattribute/{app}/{key}', array('OC_OCS_Privatedata', 'get'), 'ocs');
|
OC_API::register('get', '/privatedata/getattribute/{app}/{key}', array('OC_OCS_Privatedata', 'get'), 'ocs');
|
||||||
OC_API::register('post', '/privatedata/setattribute/{app}/{key}', array('OC_OCS_Privatedata', 'set'), 'ocs');
|
OC_API::register('post', '/privatedata/setattribute/{app}/{key}', array('OC_OCS_Privatedata', 'set'), 'ocs');
|
||||||
OC_API::register('post', '/privatedata/deleteattribute/{app}/{key}', array('OC_OCS_Privatedata', 'delete'), 'ocs');
|
OC_API::register('post', '/privatedata/deleteattribute/{app}/{key}', array('OC_OCS_Privatedata', 'delete'), 'ocs');
|
||||||
|
|
Loading…
Reference in New Issue