From 7a24f0cd8d28e60360127da19e40bff4b2e04168 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Mon, 30 Jul 2012 21:03:41 +0200 Subject: Make calling ocs/v1.php/config work --- lib/api.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'lib/api.php') diff --git a/lib/api.php b/lib/api.php index fd2c621f389..515bab6714e 100644 --- a/lib/api.php +++ b/lib/api.php @@ -43,7 +43,8 @@ class OC_API { $name = str_replace(array('/', '{', '}'), '_', $name); if(!isset(self::$actions[$name])){ OC::$router->create($name, $url.'.{_format}') - ->defaults(array('_format'=>'xml')) + ->defaults(array('_format' => 'xml')) + ->requirements(array('_format' => 'xml|json')) ->action('OC_API', 'call'); self::$actions[$name] = array(); } @@ -55,7 +56,7 @@ class OC_API { * @param array $parameters */ public static function call($parameters){ - $name = $parameters['_name']; + $name = $parameters['_route']; // Loop through registered actions foreach(self::$actions[$name] as $action){ $app = $action['app']; @@ -107,8 +108,14 @@ class OC_API { * @param int|array $response the response * @param string $format the format xml|json */ - private function respond($response, $format='json'){ - // TODO respond in the correct format + private static function respond($response, $format='json'){ + if ($format == 'json') { + echo json_encode($response); + } else if ($format == 'xml') { + // TODO array to xml + } else { + var_dump($format, $response); + } } -} \ No newline at end of file +} -- cgit v1.2.3