Extension:ApiMagicWord
| This extension stores its source code on a wiki page. Please be aware that this code may be unreviewed or maliciously altered. They may contain security holes, outdated interfaces that are no longer compatible etc. Note: No localisation updates are provided for this extension by translatewiki.net. |
| The author of this extension is no longer maintaining it! Meaning any reports for additional features and/or bugfixes will more than likely be ignored. Volunteers are encouraged to take on the task of developing and maintaining it. As a courtesy, you may want to contact the author. You should also remove this template and list yourself as maintaining the extension in the page's {{extension}} infobox. |
|
ApiMagicWord Release status: experimental |
|||
|---|---|---|---|
| Implementation | Parser function | ||
| Description | ApiMagicWord extension provide a wiki text access to enabled Application Programming Interfaces (API) of MediaWiki Web sites. | ||
| Author(s) | Eric Larchertalk | ||
| Last version | 0.1b | ||
| License | GPL | ||
| Download | No link | ||
|
|||
| Check usage and version matrix; stats | |||
Contents |
What can this extension do?[edit]
With a simple magic word #api, ApiMagicWord extension enabled wiki text access to the (enabled :-) Application Programming Interfaces (API) of MediaWiki Web sites.
By this way, it permits to interact, to get and post data from within each wiki page, with all the contents of those sites .
From within each wiki page with all the contents of the local site included, if its API is enabled.
Usage[edit]
Here, you can find some examples of the syntax call to http://fr.wikipedia.org/w/api.php (the API of the french wikipedia) from another Mediawiki wiki:
Note 1 : That suppose that, in the local wiki, wfrapi was declared as an interwikilink for http://fr.wikipedia.org/w/api.php?action=$1.
Note 2 : ApiMagicWord suppose too a simple relation between interwikilink to index.php and interwikilink to api.php : if wfrapi is an interwikilink for http://fr.wikipedia.org/w/api.php?action=$1, wfr is (one of) the interwikilink for http://fr.wikipedia.org/w/index.php?title=$1.
- {{#api:wfrapi|action=query|list=recentchanges}}
- {{#api:wfrapi|action=query|list=recentchanges|rcprop=user{{!}}comment{{!}}flags{{!}}timestamp{{!}}title{{!}}ids{{!}}sizes}}
- {{#api:wfrapi|action=login|lgname=Eric Larcher|lgpassword=...}}
- {{#api:wfrapi|action=logout}}
Remark :For meaning of {{!}}, see Template:!.
To format the results[edit]
Templates can be used to filter and/or format items send to the current wiki page :
Remark : of course, for a correct rendering, the templates have to bee create before their usage.
- {{#api:wfrapi|action=login|lgname=Eric Larcher|lgpassword=...|template=Api/login}}
- {{#api:wfrapi|action=edit|title=Utilisateur:Eric Larcher/callintertrans|text=encore un nouvel essai api|summary=test api||notbot/template=Api/edit}}
- {{#api:wfrapi|action=query|list=recentchanges|template=Api/query/recentchanges}}
- {{#api:wfrapi|action=query|list=recentchanges|template=Api/query/recentchanges2|rcprop=user{{!}}comment{{!}}flags{{!}}timestamp{{!}}title{{!}}ids{{!}}sizes}}
- {{#api:|action=logout|template=Api/Void}}
Tips : As in the line above, it's possible to use an empty template to avoid all trace in the rendered wiki text.
Others ways, are :
- when the result is not a list of more than one list of results :
{{Api/query/anothertemplateapproach|{{subst:#api:wfrapi|action=query|list=recentchanges|rclimit=1}}}}.
- (since version 0.1c) when the result is a list of one or more list of results :
{{#arraymap:{{#api:wfrapi|action=query|list=recentchanges|rclimit=10|delimiter=&&}}|&&|x|{{Api/query/recentchanges|x}}|</tr><tr>}}, if for example we want to build a table.
Remark : Of course, for that,#arraymapshould be active. See Extension:Semantic Forms.
Access to the Api of a local Mediawiki wiki[edit]
For access to the Api of the local Mediawiki wiki, no need to specify an interwikilink :
- {{#api:|action=query|list=recentchanges|template=Api/query/recentchanges}}
- {{#api:|action=logout|template=Void}}
- {{#api:|action=edit|title=Utilisateur:Eric Larcher/callintertrans|text=je recommence encore encore un nouvel essai api|notbot|summary=test api}}
ToDo[edit]
A lot of work !! Every help is welcome !
Download instructions[edit]
Please cut and paste the codes found in subpages :
- ApiMagicWord.php : place it in
$IP/extensions/ApiMagicWord/ApiMagicWord.php. - ApiMagicWord_body.php : place it in
$IP/extensions/ApiMagicWord/ApiMagicWord_body.php. - ApiMagicWord.i18n.php : place it in
$IP/extensions/ApiMagicWord/ApiMagicWord.i18n.php. - ApiMagicWord.i18n.magic.php : place it in
$IP/extensions/ApiMagicWord/ApiMagicWord.i18n.magic.php. - customwikibot.classes.php : place it in
$IP/extensions/ApiMagicWord/customwikibot.classes.php.
Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php.
Installation[edit]
To install this extension, add the following to LocalSettings.php:
#add configuration parameters here #setup user rights here require_once("$IP/extensions/ApiMagicWord/ApiMagicWord.php");
Configuration parameters[edit]
If $wgApiMagicWordUseNoPrefixHash is set to true, then magic word api is without the preceding hash symbol, and more like a built-in function.
User rights[edit]
Have to be implemented.
Code[edit]
See :
- Extension:ApiMagicWord/ApiMagicWord.php
- Extension:ApiMagicWord/ApiMagicWord_body.php
- Extension:ApiMagicWord/ApiMagicWord.i18n.php
- Extension:ApiMagicWord/ApiMagicWord.i18n.magic.php
- Extension:ApiMagicWord/customwikibot.classes.php
See also[edit]
- ClueBot/Source
- this Sandbox for testing purpose.