[dokuwiki] Remote API RPC

  • From: Jan Zmátlík <zisanek@xxxxxxxxx>
  • To: dokuwiki <dokuwiki@xxxxxxxxxxxxx>
  • Date: Tue, 10 May 2011 21:04:33 +0200

Hi,

I have created Remote API for RPC calls. On schema
(http://www.punkradio.cz/osp/remoteapi.png) is simple representation
of implementation. JSON and XML RPC server have to implement RemoteAPI
interface.

For xml rpc server
https://github.com/zmatlja1/dokuwiki/compare/8ea8a67e25...4ae25ac47e#diff-4
For json rpc server
https://github.com/zmatlja1/dokuwiki/compare/8ea8a67e25...4ae25ac47e#diff-5

RemoteAPI is in /inc/RemoteAPI. I have created RemoteAPI interface
according to XML/JSON dokuwiki server methods. I have found some
inconsistencies.

At first in JSON RPC plugin - jsonrpc.php
at method
function appendPage($id, $text, $opt)
{
        $page_cont = $this->rawPage($id);
        $page_cont = $page_cont."\n".$text;
        return saveWikiText($page, $tmp, $opt);
}
I had to rename parameters, because in xml rpc is it appendPage($id,
$text, $params), but $page_cont is not used and $page, $tmp is not
defined. So I edit this method according to xml rpc
https://github.com/zmatlja1/dokuwiki/commit/d4cf6fcf8badfdcb894e55455c3fb08bc91274f5#diff-3.

Method in json rpc
public function search($query) on line with code $data =
ft_pageLookup($searchStr); - $searchStr is not define, original name
of parameter was searchString. Is it a bug or not? I had to rename
searchString to query to consistent interface for xml/json.

Methods which isn't in the xml rpc server is
htmlPagePart
_media_upload_action($data)
getAPIVersion

in json rpc server isnt
wiki_RPCVersion()

I do not put into interface except getAPIVersion. getAPIVersion I
added to the json rpc. Changes in JSON plugin is in
https://github.com/zmatlja1/dokuwiki/commit/d4cf6fcf8badfdcb894e55455c3fb08bc91274f5#diff-3
So what am I doing with these methods?

Remote API is in
https://github.com/zmatlja1/dokuwiki/tree/master/inc/RemoteAPI . I not
have tested yet. I dont know how :).
I have created RPCFactoryServer which creates single instance of
specific server (XML/JSON). But in the method  where the instacne of
server is created, have to be more properties from server.

For example, before dokuwiki_xmlrpc_server is:
if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../');

// fix when '<?xml' isn't on the very first line
if(isset($HTTP_RAW_POST_DATA)) $HTTP_RAW_POST_DATA = trim($HTTP_RAW_POST_DATA);

/**
 * Increased whenever the API is changed
 */
define('DOKU_XMLRPC_API_VERSION',5);

require_once(DOKU_INC.'inc/init.php');
session_write_close();  //close session

if(!$conf['xmlrpc']) die('XML-RPC server not enabled.');

and similiar is in the json server.

I have added into load.php calls for Remote API -
https://github.com/zmatlja1/dokuwiki/commit/2070b4db43617f743762fd7b3c77a9d3cf0e6a15
I guess that interface RemoteAPI have to be in XML/JSON Plugin, am I
right? Or in load.php is satisfied?

Maybe it will need create interface for IXR/IJR errors because some of
methods returns this errors and universal rpc server dont understand
them (is instance of server will be xml server, returns xml error with
method getXml, but json have getJson). So it will need create abstract
class RPCError with method getError() and IXR/IJR have to inherit from
RPCError.

See you
Jan Zmátlík
--
DokuWiki mailing list - more info at
http://www.dokuwiki.org/mailinglist

Other related posts: