DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:jsonrpc

jsonrpc Plugin

Compatible with DokuWiki

2008-05-05

plugin JSON-RPC interface to interact with DokuWiki from other Programms using Ajax Request

Last updated on
2010-12-14
Provides
Action
Repository
Source

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Tagged with ajax, json

Download and Installation

Search and install the plugin using the Extension Manager. Refer to Plugins on how to install plugins manually.

Configuration

  • Activate/Deactivate in PluginAdminMenu
  • Permissions can be set in the “Advanced Options” section
    • You can choose “allow everyone”
    • Or “allowed users” (user1; user2; user3; user4; …)

Functions

  • dokuwiki.getPagelist
    • Parameters (string) namespace, (array) options
      • params : [{string : 'myNamespace'}]};
    • Data (array) list of page items
    • Description Lists all pages within a given namespace. The options are passed directly to search_allpages().
  • dokuwiki.getVersion
    • Parameters -
    • Data (string) version number
    • Description Returns the DokuWiki version of the remote Wiki.
  • dokuwiki.getTime
    • Parameters -
    • Data (string) timestamp
    • Description Returns the current time at the remote wiki server as Unix timestamp
  • dokuwiki.login
    • Name dokuwiki.login
    • Parameters (string) user, (string) password
      • params : [{string : “myUser”}, {string:“myPassword”}]};
    • Data (int) login successful
    • Description Uses the provided credentials to execute a login and will set cookies. This can be used to make authenticated requests afterwards. Your client needs to support cookie handling. Alternatively use HTTP basic auth credentials.
  • dokuwiki.search
    • Parameters (string) a query string as described on search
      • params : [{string : “mySearchString”}]};
    • Data (array) associative array with matching pages similar to what is returned by dokuwiki.getPagelist, snippets are provided for the first 15 results
    • Description Performs a fulltext search
  • dokuwiki.getTitle
    • Name dokuwiki.getTitle
    • Parameters -
    • Data (string) the title of the wiki
    • Description Returns the title of the wiki
  • dokuwiki.appendPage
    • Name dokuwiki.appendPage
    • Parameters (string) pagename, (string) raw Wiki text, (array) attrs
      • params : [{string : “myPage”}, {string:“myText to add to myPage \n next line”}] (dokuwiki syntax)
      • Where attrs can contain the following:
        • $attrs['sum'] = (string) change summary
        • $attrs['minor'] = (boolean) minor
    • Data (boolean)
    • Description Appends text to a Wiki Page.
  • dokuwiki.setLocks
    • Parameters (array) list of two lists of page [array('lock'⇒array(…), 'unlock'⇒array(…))],
      • params : [{ struct: { 'lock' : ['PageToLock1, …'],'unlock' : ['PageToUnlock1, …']}}]
    • Data (array) array with 4 lists of pageids array('locked'⇒array(…), 'lockfail'⇒array(…), 'unlocked'⇒array(…), 'unlockfail'⇒array(…))
    • Description Allows you to lock or unlock a whole bunch of pages at once. Useful when you are about to do a operation over multiple pages
  • wiki.getPage
    • Parameters (string) pagename
      • params : [{string : “myPage”}]
    • Data (string) raw Wiki text
    • Description Returns the raw Wiki text for a page.
  • wiki.getPageVersion
    • Parameters (string) pagename, (string) Timestamp
      • params : [{string : “myPage”}, {string : “1291985639”}]
    • Data (string) raw Wiki text
    • Description Returns the raw Wiki text for a specific revision of a Wiki page.
  • wiki.getPageVersions
    • Parameters (string) pagename, (string) firstPage(timestamp)
      • params : [{string : “myPage”}, {string : “1291975639”}]
    • Data (array) each array item holds the following data:
      • $data['user'] = username
      • $data['ip'] = ip address
      • $data['type'] = type of change
      • $data['sum'] = summary
      • $data['modified'] = modification date as UTC timestamp
      • $data['version'] = page version as timestamp
    • Description Returns the available versions of a Wiki page. The number of pages in the result is controlled via the recent configuration setting. The offset can be used to list earlier versions in the history.
  • wiki.getPageInfo
    • Parameters (string) pagename
      • params : [{string : “myPage”}]
    • Data (array) an array containing the following data:
      • $data['name'] = [[pagename]]
      • $data['lastModified'] = modifaction date as UTC timestamp
      • $data['author'] = author of the Wiki page.
      • $data['version'] = page version as timestamp
    • Description Returns information about a Wiki page.
  • wiki.getPageInfoVersion
    • Parameters (string) pagename, (string) timestamp
      • params : [{string : “myPage”}, {string : “1291985639”}]
    • Data (array) an array containing the following data:
      • $data['name'] = [[:pagename]]
      • $data['lastModified'] = modification date as UTC timestamp
      • $data['author'] = author of the Wiki page.
      • $data['version'] = page version as timestamp
    • Description Returns information about a specific version of a Wiki page.
  • wiki.getPageHTML
    • Parameters (string) pagename
      • params : [{string : “myPage”}]
    • Data (string) rendered HTML
    • Description Returns the rendered XHTML body of a Wiki page.
  • wiki.getPageHTMLVersion
    • Name wiki.getPageHTMLVersion
    • Parameters (string) pagename, (string) timestamp
      • params : [{string : “myPage”}, {string : “1291985639”}]
    • Data (string) rendered HTML
    • Description Returns the rendered HTML of a specific version of a Wiki page.
  • wiki.putPage
    • Parameters (string) pagename, (string) raw Wiki text, (array) attrs
      • params : [{string : “myPage”}, {string : “==== MyNewPage ==== \nThis is my new Page”}]
      • Where attrs can contain the following:
        • $attrs['sum'] = (string) change summary
        • $attrs['minor'] = (boolean) minor
    • Data (boolean)
    • Description Saves a Wiki Page.
  • wiki.listLinks
    • Parameters (string) pagename
      • params : [{string : “myPage”}]
    • Data (array) each array item holds the following data:
      • $data['type'] = local/extern
      • $data['page'] = the wiki page (or the complete URL if extern)
      • $data['href'] = the complete URL
    • Description Returns a list of all links contained in a Wiki page.
  • wiki.getAllPages
    • Parameters -
    • Data (array) One item for each page, each item containing the following data:
      • $data['id'] = id of the page
      • $data['perms'] = integer denoting the permissions on the page
      • $data['size'] = size in bytes
      • $data['lastModified'] = dateTime object of last modification date
    • Description Returns a list of all Wiki pages in the remote Wiki.
  • wiki.getBackLinks
    • Parameters (string) pagename
      • params : [{string : “myPage”}]
    • Data (array)
    • Description Returns a list of backlinks of a Wiki page.
  • wiki.getRecentChanges
    • Name wiki.getRecentChanges
    • Parameters (string) timestamp
      • params : [{string : “1291985639”}]
    • Data (array) each array item holds the following data:
      • $data['name'] = page id
      • $data['lastModified'] = modification date as UTC timestamp
      • $data['author'] = author
      • $data['version'] = page version as timestamp
    • Description Returns a list of recent changes since given timestamp.
  • wiki.getAttachments
    • Parameters (String) namespace, (array) options
      • params : [{string : “myNamespace”}]
    • Data (array) each array item holds the following data:
      • $data['id'] = media id
      • $data['size'] = size in bytes
      • $data['lastModified'] = modification date as XMLRPC Date object
      • $data['isimg'] = true if file is an image, false otherwise
      • $data['writable'] = true if file is writable, false otherwise
      • $data['perms'] = permissions of file
    • Description Returns a list of media files in a given namespace.
      • Available options are:
        • $options['recursive'] = true if also files in subnamespaces are to be included, defaults to false
        • $options['pattern'] = an optional PREG compatible regexp which has to match the file id
  • wiki.getAttachment
    • Parameters (String) id
      • params : [{string : “myPicture.png”}]
    • Data (base64) the data of the file, encoded in base64
    • Description Returns the binary data of a media file
  • wiki.getAttachmentInfo
    • Parameters (String) id
      • params : [{string : “myPicture.png”}]
    • Data (array) an array containing the following information about the file:
      • $data['size'] = size in bytes
      • $data['lastModified'] = modification date as XMLRPC Date object
    • Description Returns information about a media file
  • wiki.putAttachment
    • Parameters (String) id, (base64) data, (array) params (optional)
      • params : [{string : “myPicture.png”}, {base64 : “EA2DD…”}]
    • Data -
    • Description Uploads a file as a given media id. Available parameters are:
    • $params['ow'] = true if file is to overwrite an already existing media object of the given id
  • wiki.deleteAttachment
    • Parameters (String) id
      • params : [{string : “myPicture.png”}]
    • Data -
    • Description Deletes a file. Fails if the file is still referenced from any page in the wiki.

Request (method invocation)

Properties:

  • method - method name as string
  • params - arguments as array of objects
  • id - Request id

Response

Serverresponse, properties:

  • result - return object (if(error)result = null)
  • error - error object, if failure, else = null
    • code: error code as integer
    • message: description of the error
    • data: additional info about errors
  • id - same id as id in Request

ErrorCodes

Code Message Description
-32700 Parse error Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text.
-32600 Invalid Request The JSON sent is not a valid Request object.
-32601 Method not found The method does not exist / is not available.
-32602 Invalid params Invalid method parameter(s).
-32603 Internal error Internal JSON-RPC error.
-32099 to -32000 Server error Reserved for implementation-defined server-errors.

Programm components

  • jsonrpc.php
    • get Callback functions(Wiki) from IJR_CallbackDefines
    • Authentication
    • Wiki functions
  • IJR_IntrospectionServer.php
    • Verify Functions (Function exists, count of parameters, righteoussnes Parameter)
  • IJR_Server.php
    • Set callback Capabillities (multicall, single call, list methods)
    • Generate the output (console in firebug)
    • call functions
    • Ajax Request
  • IJR_Message.php
  • IJR_Error.php
    • returns error code and message of Ajax Request
  • IJR_Date.php
    • Date functions
  • IJR_Base64.php
    • base64 encode

Javascript(YUI) Sample Code

  YUI().use("io-base", function(Y) {
      var uri = sUrl + 'Your/Path/To/DokuWiki/lib/plugins/jsonrpc/jsonrpc.php';
      var js_request = {
          jsonrpc: '2.0',
          id: '',
          method : {
              methodName : 'wiki.putPage'
          },
          params : [
              {string : 'myNamespace:myPage'},
              {string : "==== myPage ==== \n This is my new Page!"}
          ]};
      var json_request  = YAHOO.lang.JSON.stringify(js_request);
      var cfg = {
          method: 'POST',
          data:json_request,
          headers: {
              'Content-Type':'application/json'
          },
          arguments: p.obj
      }
      var request = Y.io(uri,cfg);
  });
plugin/jsonrpc.txt · Last modified: 2023-10-31 01:00 by Klap-in

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki