Current Version:
0.1 Beta
Running @ wikidot.comule.com
Accessing the Wikidot API through Javascript isn't particularly easy - especially when the page to which the API is interacting from is from a remote server. Now with Wikidot JSONAPI, you are able to interact with Wikidot's API from remote locations (domains other than Wikidot's own) through JSONP.
JSONAPI is powered by a PHP Backend - translating JSON requests to a XML-RPC request. Once the data is returned - the data is decoded from XML and re-encoded back into the JSON format. Finally, the script executed with a callback function.
JSONAPI is accessible at http://wikidot.comule.com/json.php with the following request values:
Name | Value |
---|---|
method | an API Method - full list here |
key | your API Key |
request | JSON request string - please ensure that the request is in string form |
callback | the callback function - returns a single argument with JSON data. Returns false during errors |
Example
The following example uses jQuery and its getJSON() function. This script can be executed anywhere in the world-wide web and there will be no problems with cross-domain HTTP requests.
<html> <head> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> <script type="text/javascript"> $.getJSON("http://wikidot.comule.com/json.php?callback=?", { method: "pages.get_one", //API Method key: "12345678901234567890123456789012", //API Key request: '{"site":"my-site","page":"a-page"}' //API Request in JSON }, function(data) { $("#return").html(data.fullname); }); </script> </head> <body> This is an example of JSONAPI in action. <div id="return">Loading...</div> </body> </html>