devel:xmlrpc
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
devel:xmlrpc [2017-09-02 10:08] – [XML-RPC] 59.63.249.176 | devel:xmlrpc [2018-05-29 13:48] – andi | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== XML-RPC ====== | ====== XML-RPC ====== | ||
- | [[: | ||
- | DokuWiki has an experimental | + | DokuWiki has a [[wp> |
+ | |||
+ | Plugins can add their own calls to the API using [[devel: | ||
Questions and suggestions to extend and improve the API should be directed to the [[: | Questions and suggestions to extend and improve the API should be directed to the [[: | ||
+ | |||
===== Get It Working ===== | ===== Get It Working ===== | ||
- You need at least the 2008-03-31 release of DokuWiki. | - You need at least the 2008-03-31 release of DokuWiki. | ||
Line 19: | Line 21: | ||
===== Sample XML Requests ===== | ===== Sample XML Requests ===== | ||
+ | |||
+ | Note: you should use an XML-RPC library instead of hand-crafting your requests. | ||
+ | |||
Here is an example of how to post to the API: | Here is an example of how to post to the API: | ||
+ | |||
<code xml> | <code xml> | ||
POST /RPC2 HTTP/1.0 | POST /RPC2 HTTP/1.0 | ||
Line 62: | Line 68: | ||
< | < | ||
< | < | ||
- | < | + | < |
- | Report Created on 2017-05-25 16:23:37 | + | |
- | ===== Servers ===== | + | |
- | ^ID ^Name ^Description ^IP ^Type ^OS ^Last Scan ^ | + | |
- | |18 |[[: | + | |
- | + | ||
- | </ | + | |
</ | </ | ||
</ | </ | ||
Line 162: | Line 162: | ||
^ Description | Allows you to lock or unlock a whole bunch of pages at once. Useful when you are about to do an operation over multiple pages. | | ^ Description | Allows you to lock or unlock a whole bunch of pages at once. Useful when you are about to do an operation over multiple pages. | | ||
^ Since | 2009-03-06 (1) | | ^ Since | 2009-03-06 (1) | | ||
+ | |||
+ | ==== dokuwiki.deleteUsers ==== | ||
+ | |||
+ | ^ Name | '' | ||
+ | ^ Parameters | ||
+ | ^ Data | (bool) true if the users were deleted | | ||
+ | ^ Description | Allows you to delete one or more users. Useful to implement GDPR right to be forgotten tools. | | ||
+ | ^ Since | 2018-05-24 | | ||
==== wiki.getRPCVersionSupported ==== | ==== wiki.getRPCVersionSupported ==== | ||
Line 382: | Line 390: | ||
* -99999 -> Unknown server error. | * -99999 -> Unknown server error. | ||
- | ===== Sample | + | ===== Sample |
- | A java client for Dokuwiki is available on [[https:// | + | |
- | + | ||
- | Example which displays the title of the wiki and the list of its pages: | + | |
- | <code java> | + | |
- | import dw.xmlrpc.DokuJClient; | + | |
- | import dw.xmlrpc.Page; | + | |
- | + | ||
- | public class Main { | + | |
- | public static void main(String[] args) throws Exception{ | + | |
- | String url = " | + | |
- | String user = " | + | |
- | String pwd = " | + | |
- | + | ||
- | DokuJClient client = new DokuJClient(url, | + | |
- | System.out.println(" | + | |
- | for(Page page : client.getAllPages()){ | + | |
- | System.out.println(page.id()); | + | |
- | } | + | |
- | + | ||
- | } | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | ===== Sample PHP Client ===== | + | |
- | This simple example will pull the version information from the given DokuWiki. | + | |
- | + | ||
- | * You need to download and install the library [[http:// | + | |
- | * The URL of the DW-Server must be given **without** the procotol (< | + | |
- | + | ||
- | <code php> | + | |
- | <?php | + | |
- | include(' | + | |
- | + | ||
- | // create a new client instance | + | |
- | $c = new xmlrpc_client('/ | + | |
- | + | ||
- | // enable debugging to see more infos :-) (well, not for production code) | + | |
- | $c-> | + | |
- | + | ||
- | // create the XML message to send | + | |
- | $m = new xmlrpcmsg(' | + | |
- | + | ||
- | // send the message and wait for response | + | |
- | $r = $c-> | + | |
- | if($r == false) die(' | + | |
- | if(!$r-> | + | |
- | // seems good. Now do whatever you want with the data | + | |
- | $v = php_xmlrpc_decode($r-> | + | |
- | echo " | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | <code php> | + | |
- | <?php | + | |
- | include('/ | + | |
- | + | ||
- | $c = new xmlrpc_client('/ | + | |
- | $c-> | + | |
- | + | ||
- | $m = new xmlrpcmsg(' | + | |
- | $m-> | + | |
- | $m-> | + | |
- | $m-> | + | |
- | + | ||
- | $r = $c-> | + | |
- | if($r == false) die(' | + | |
- | + | ||
- | // Output the response object | + | |
- | // var_dump($r); | + | |
- | $r = $c-> | + | |
- | + | ||
- | if(!$r-> | + | |
- | $v = php_xmlrpc_decode($r-> | + | |
- | echo $v; | + | |
- | } else { | + | |
- | echo $r-> | + | |
- | } | + | |
- | + | ||
- | ?> | + | |
- | </ | + | |
- | + | ||
- | DokuWiki has its own XML-RPC library which could also be used. A simple client using that library looks like this: | + | |
- | + | ||
- | <code php> | + | |
- | <?php | + | |
- | require_once(' | + | |
- | + | ||
- | $client = new IXR_Client(' | + | |
- | $client-> | + | |
- | $client-> | + | |
- | $ok = $client-> | + | |
- | if($ok) { | + | |
- | | + | |
- | echo $client-> | + | |
- | } | + | |
- | </ | + | |
- | + | ||
- | ===== Sample Perl Client ===== | + | |
- | + | ||
- | [[https:// | + | |
- | + | ||
- | you can also write RPC:: | + | |
- | + | ||
- | <code perl> | + | |
- | use strict; | + | |
- | use warnings; | + | |
- | use feature ' | + | |
- | use RPC:: | + | |
- | use Data:: | + | |
- | + | ||
- | my $client = | + | |
- | RPC:: | + | |
- | + | ||
- | my $res = $client-> | + | |
- | say ' | + | |
- | + | ||
- | my $namespace = ' | + | |
- | my $req = | + | |
- | RPC:: | + | |
- | RPC:: | + | |
- | RPC:: | + | |
- | $res = $client-> | + | |
- | say " | + | |
- | + | ||
- | + | ||
- | # if given and >0 ' | + | |
- | # setting ' | + | |
- | $res = $client-> | + | |
- | RPC:: | + | |
- | RPC:: | + | |
- | RPC:: | + | |
- | ) | + | |
- | ); | + | |
- | say " | + | |
- | + | ||
- | + | ||
- | </ | + | |
- | + | ||
- | ===== Sample Ruby Client ===== | + | |
- | This simple example will pull the version information from the given Dokuwiki. No plugin required (in the Windows default package). | + | |
- | <code ruby> | + | |
- | require " | + | |
- | server = XMLRPC:: | + | |
- | begin | + | |
- | puts server.call(" | + | |
- | rescue XMLRPC:: | + | |
- | puts " | + | |
- | puts e.faultCode | + | |
- | puts e.faultString | + | |
- | end | + | |
- | </ | + | |
- | + | ||
- | This example demonstrates how to upload attachments: | + | |
- | + | ||
- | <code ruby> | + | |
- | require " | + | |
- | server = XMLRPC:: | + | |
- | begin | + | |
- | puts server.call(" | + | |
- | rescue XMLRPC:: | + | |
- | puts " | + | |
- | puts e.faultCode | + | |
- | puts e.faultString | + | |
- | end | + | |
- | </ | + | |
- | + | ||
- | ===== Sample jQuery Client ===== | + | |
- | <code javascript> | + | |
- | var xml='<? | + | |
- | | + | |
- | url: " | + | |
- | data: xml, | + | |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | }, | + | |
- | }); | + | |
- | </ | + | |
- | + | ||
- | ===== Python Module ===== | + | |
- | A Python module for DokuWiki' | + | |
- | + | ||
- | Alternative: | + | |
- | + | ||
- | + | ||
- | ===== Sample AutoIt3 Client ===== | + | |
- | My AutoIt3 client is mainly a proof of concept: | + | |
- | + | ||
- | <code autoit> | + | |
- | #cs ---------------------------------------------------------------------------- | + | |
- | + | ||
- | | + | |
- | | + | |
- | + | ||
- | | + | |
- | XML-RPC sample client AutoIt3 script. | + | |
- | + | ||
- | #ce ---------------------------------------------------------------------------- | + | |
- | + | ||
- | ; this script uses the UDF WinHttp | + | |
- | #include " | + | |
- | + | ||
- | ; get the info from page ' | + | |
- | $Xml = '<? | + | |
- | $Xml = $Xml & @CRLF & '< | + | |
- | $Xml = $Xml & @CRLF & '< | + | |
- | $Xml = $Xml & @CRLF & '< | + | |
- | $Xml = $Xml & @CRLF & '< | + | |
- | $Xml = $Xml & @CRLF & '< | + | |
- | $Xml = $Xml & @CRLF & '< | + | |
- | $Xml = $Xml & @CRLF & '</ | + | |
- | $Xml = $Xml & @CRLF & '</ | + | |
- | $Xml = $Xml & @CRLF & '</ | + | |
- | $Xml = $Xml & @CRLF & '</ | + | |
- | $XmlSize = StringLen($Xml) | + | |
- | + | ||
- | ; initializes the use of WinHTTP functions and returns a WinHTTP-session handle. | + | |
- | $hw_open = _WinHttpOpen() | + | |
- | + | ||
- | ; creates a HTTP request handle to a lokal DokuWikiStick installation on port 8800 | + | |
- | $hw_connect = _WinHttpConnect($hw_open, | + | |
- | + | ||
- | ; creates a HTTP request handle | + | |
- | $h_openRequest = _WinHttpOpenRequest($hw_connect, | + | |
- | + | ||
- | ; sends the specified request to the HTTP server | + | |
- | _WinHttpSendRequest($h_openRequest, | + | |
- | + | ||
- | ; waits to receive the response to a HTTP request initiated by WinHttpSendRequest(). | + | |
- | _WinHttpReceiveResponse($h_openRequest) | + | |
- | + | ||
- | $Data = "" | + | |
- | Do | + | |
- | ; reads data from a handle opened by the _WinHttpOpenRequest() function. | + | |
- | $Data& | + | |
- | Until @error | + | |
- | + | ||
- | ; close connection and clean up | + | |
- | _WinHttpCloseHandle($h_openRequest) | + | |
- | _WinHttpCloseHandle($hw_connect) | + | |
- | _WinHttpCloseHandle($hw_open) | + | |
- | + | ||
- | ; show error number and resulting data | + | |
- | MsgBox(4096," | + | |
- | </ | + | |
- | + | ||
- | ===== Sample Emacs Lisp Client ===== | + | |
- | <code lisp> | + | |
- | + | ||
- | (require ' | + | |
- | (defvar *dokuwiki-xml-rpc-url* " | + | |
- | (xml-rpc-method-call | + | |
- | *dokuwiki-xml-rpc-url* | + | |
- | ' | + | |
- | + | ||
- | </ | + | |
- | + | ||
+ | A number of [[devel: |
devel/xmlrpc.txt · Last modified: 2024-01-31 23:57 by Klap-in