Extension:Webservice

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manualManual:Extensions
Crystal Clear action run.png
Webservice

Release status:Extension status stable

ImplementationTemplate:Extension#type Tag, Parser function
DescriptionTemplate:Extension#description Pull data from an external webservice into a wiki page
Author(s)Template:Extension#username Chris Reigrut, Key Bank / Key Equipment Finance
Latest versionTemplate:Extension#version 0.3.0 (03/20/2009)
MediaWikiTemplate:Extension#mediawiki 1.11 - 1.13
LicenseTemplate:Extension#license No license specified
Download Extension:Webservice#Installation
ParametersTemplate:Extension#parameters

$wgHTTPProxyExceptions

Translate the Webservice extension if it is available at translatewiki.net

Check usage and version matrix.

This extension allows you to easily include information from an external webservice into a wiki page. For instance, you could pull data from a web page, an XML feed, etc.

It currently requires an internal version of tidy and PHP5. I'll likely add external Tidy and pre-PHP5 support at some point.

Usage[edit]

This is a function extension primarily, and takes three parameters (in order):

URL
The full url of the webservice that you wish to use
Wikitext
The wikitext to insert into the page--additionally, anything between % signs will be replaced with the result of executing that text as an XPath string on the document returned from the URL.
Options
Currently, there are three possible options:
  • IE - Impersonate Internet Explorer (by changing the user-agent)
  • TIDY-XHTML - Run tidy on the document returned from the URL, converting it to XHTML
  • COOKIE:key=value - Insert a cookie specified by the key and value into the request headers
  • ENCODING:value - The encoding of the web service information (needed by Tidy: see The Tidy documentation for valid values). Defaults to utf8.

Example[edit]

{{#webservice:http://www.w3c.org|The title of the webpage at http://www.w3c.org is %//html/head/title%}}

Installation[edit]

  1. Create a directory called Webservice in your extensions directory
  2. Download webservice.php into your Webservice directory

Parameters[edit]

If you are behind a proxy (i.e. you have set $wgHTTPProxy in LocalSettings.php), you can set an additional variable $wgHTTPProxyExceptions which is an array of URL patterns to exclude from the proxy. For example:

$wgHTTPProxyExceptions = array(
	'/^(http:\/\/|https:\/\/)?([^\.]*\.)?key\.com(\/|\?|&|$)/i',
	'/^(http:\/\/|https:\/\/)?([^\.]*\.)?keybank\.com(\/|\?|&|$)/i',
	'/^(http:\/\/|https:\/\/)?([^\.]*\.)?mdd\.com(\/|\?|&|$)/i',
);

would exclude any URLs that end in key.com, keybank.com or mdd.com.

Changes to LocalSettings.php[edit]

require_once("$IP/extensions/Webservice/webservice.php");

Revision History[edit]

0.3.0 (03/20/2009)
Minor fixes to error handling

Sites using this extension[edit]

Please add your site (and a link if it is public) to the list! Thanks!

  • Key National Finance WiKey (internal intranet)