xref: /dokuwiki/lib/exe/jsonrpc.php (revision f657e5d050d6b1d1cb1ea1c656f5aec61f5067de)
1*f657e5d0SAndreas Gohr<?php
2*f657e5d0SAndreas Gohr
3*f657e5d0SAndreas Gohruse dokuwiki\Remote\JsonRpcServer;
4*f657e5d0SAndreas Gohr
5*f657e5d0SAndreas Gohrif (!defined('DOKU_INC')) define('DOKU_INC', __DIR__ . '/../../');
6*f657e5d0SAndreas Gohr
7*f657e5d0SAndreas Gohrrequire_once(DOKU_INC . 'inc/init.php');
8*f657e5d0SAndreas Gohrsession_write_close();  //close session
9*f657e5d0SAndreas Gohr
10*f657e5d0SAndreas Gohrheader('Content-Type: application/json');
11*f657e5d0SAndreas Gohr
12*f657e5d0SAndreas Gohr$server = new JsonRpcServer();
13*f657e5d0SAndreas Gohrtry {
14*f657e5d0SAndreas Gohr    $result = [
15*f657e5d0SAndreas Gohr        'error' => [
16*f657e5d0SAndreas Gohr            'code' => 0,
17*f657e5d0SAndreas Gohr            'message' => 'success'
18*f657e5d0SAndreas Gohr        ],
19*f657e5d0SAndreas Gohr        'data' => $server->serve(),
20*f657e5d0SAndreas Gohr    ];
21*f657e5d0SAndreas Gohr} catch (\Exception $e) {
22*f657e5d0SAndreas Gohr    $result = [
23*f657e5d0SAndreas Gohr        'error' => [
24*f657e5d0SAndreas Gohr            'code' => $e->getCode(),
25*f657e5d0SAndreas Gohr            'message' => $e->getMessage()
26*f657e5d0SAndreas Gohr        ],
27*f657e5d0SAndreas Gohr        'data' => null,
28*f657e5d0SAndreas Gohr    ];
29*f657e5d0SAndreas Gohr}
30*f657e5d0SAndreas Gohr
31*f657e5d0SAndreas Gohrecho json_encode($result);
32