Hook into Wikipedia information using PHP and the MediaWiki API

Use PHP to search, retrieve, and modify Wikipedia entries through the MediaWiki API

Wikipedia is the ultimate online encyclopedia, containing millions of entries on different aspects of human knowledge. Web application developers are able to access and search these entries through the Wikipedia API. This article introduces the Wikipedia API and demonstrates it in the context of a PHP application, explaining how to search and retrieve different elements of Wikipedia content with PHP.

Vikram Vaswani, Founder, Melonfire

Photo of Vikram VaswaniVikram Vaswani is the founder and CEO of Melonfire, a consulting services firm with special expertise in open-source tools and technologies. He is also the author of the books Zend Framework: A Beginners Guide and PHP: A Beginners Guide.



17 May 2011

Also available in Chinese Russian Japanese Spanish

Introduction

Frequently used acronyms

  • API: Application program interface
  • CSRF: Cross-site request forgery
  • HTML: Hypertext Markup Language
  • HTTP: Hypertext Transfer Protocol
  • IP: Internet Protocol
  • JSON: JavaScript Object Notation
  • OOP: Object-oriented programming
  • PEAR: PHP Extension and Application Repository
  • REST: REpresentational State Transfer
  • WDDX: Web Distributed Data eXchange
  • XHTML: Extensible Hypertext Markup Language
  • XML: Extensible Markup Language
  • YAML: YAML Ain't Markup Language

Most people have heard of Wikipedia: It's the ultimate repository of crowd-sourced knowledge, covering almost every subject you can think of and available to anyone with a web browser. Regardless of what information you seek, you can find it on Wikipedia, often in exhaustive detail. And because it's publicly editable, it always contains updated and relevant information.

Most people don't know one thing about Wikipedia. Hidden behind the scenes is a strong web service API, which allows developers to access, search, and integrate Wikipedia content into custom web applications. This API, which works over HTTP and returns data in a variety of different formats, including XML, is freely available to the programming public and makes it possible to create all kinds of custom web applications powered by Wikipedia's huge content database.

In this article, I give you a quick introduction to this API, showing you how to integrate and use it with my favourite programming language, PHP. This article explains the basics of how the API works and then gives you a practical walkthrough of listing categories, searching for entries by category or keyword, retrieving and displaying entries, and remotely adding and editing content.


Understanding the API

Before diving into the PHP code, a few words about the Wikipedia API are in order. First, although I call it the "Wikipedia API" in this article, it's important to note that the API is not unique to Wikipedia alone. It's actually a part of the MediaWiki base application on which Wikipedia runs, and so the techniques and API methods outlined in this article can also be used on any other MediaWiki-based wiki. You can find links to both MediaWiki and the complete MediaWiki API reference manual in Resources.

As with all HTTP-based services, the API works by accepting HTTP requests containing one or more input arguments and returning responses that can be parsed and used by the requesting client. More often than not, the response is in XML format, as almost every programming language today can parse XML; however, it's also possible to request responses in other formats, such as JSON, WDDX, YAML, or PHP serialized.

Each HTTP request to the API must contain a mandatory "action" parameter, which specifies the action required. This parameter might be a query, an edit or delete operation, an authentication request, or any one of the other supported actions. In addition to this mandatory parameter, and depending on the operation selected, additional arguments must be passed—for example, a search keyword for queries, a page title for edit or delete operations, or a username and password for authentication.

To see the API in action, try accessing the following URL in your favourite web browser. (Note: This URL is actually a single string of characters. For formatting purposes only, the URL appears as two lines.)

http://en.wikipedia.org/w/api.php?action=query&list=allcategories&acprop=size
          &acprefix=hollywood&format=xml

This method returns a list of the first 10 Wikipedia categories beginning with the prefix "hollywood". Listing 1 illustrates the raw XML response to this request.

Listing 1. An example API feed
<?xml version="1.0"?>
<api>
  <query>
    <allcategories>
      <c size="31" pages="28" files="0" subcats="3" 
        xml:space="preserve">Hollywood</c>
      <c size="0" pages="0" files="0" subcats="0" 
        xml:space="preserve">Hollywood's Rock Walk inductees</c>
      <c size="0" pages="0" files="0" subcats="0" 
        xml:space="preserve">Hollywood, California</c>
      <c size="1" pages="1" files="0" subcats="0" 
        xml:space="preserve">Hollywood, Florida</c>
      <c size="0" pages="0" files="0" subcats="0" 
        xml:space="preserve">Hollywood, Los Angeles, California</c>
      <c size="0" pages="0" files="0" subcats="0" 
        xml:space="preserve">Hollywood.com/celebrity/Wanda Shelley</c>
      <c size="0" pages="0" files="0" subcats="0" 
        xml:space="preserve">Hollywood Actors</c>
      <c size="0" pages="0" files="0" subcats="0" 
        xml:space="preserve">Hollywood Actress</c>
      <c size="0" pages="0" files="0" subcats="0" 
        xml:space="preserve">Hollywood Blacklist</c>
      <c size="2" pages="2" files="0" subcats="0" 
        xml:space="preserve">Hollywood Boulevard</c>
    </allcategories>
  </query>
  <query-continue>
    <allcategories acfrom="Hollywood Cemetery (Richmond)" />
  </query-continue>
</api>

Listing categories and pages

Now that you understand how the API works, let's look at some code. I assume throughout this article that you're familiar with HTML and XML and that you have a working Apache/PHP development environment with the latest version of the Zend Framework installed. I also assume that you know the basics of working with classes and objects in PHP, as the PHP components used in this article are written in compliance with OOP principles.

To interact with the API, you need an HTTP client that is capable of transmitting GET and POST requests and handling responses. A good tool for this is the Zend Framework's Zend_Rest_Client component, which is designed specifically for developers trying to integrate PHP applications with web services. This client can be used to perform GET, POST, PUT, and DELETE responses to a service endpoint. XML responses are returned as instances of Zend_Rest_Client_Response objects, making it easy to access individual response properties.

Listing 2 illustrates the process of retrieving and displaying the categories in Listing 1, using Zend_Rest_Client in the context of a PHP script.

Listing 2. Listing Wikipedia categories
<?php
// load Zend classes
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Rest_Client');

// define category prefix
$prefix = 'hollywood';

try {
  // initialize REST client
  $wikipedia = new Zend_Rest_Client('http://en.wikipedia.org/w/api.php');

  // set query parameters
  $wikipedia->action('query');
  $wikipedia->list('allcategories');
  $wikipedia->acprefix($prefix);
  $wikipedia->format('xml');

  // perform request
  // iterate over XML result set
  $result = $wikipedia->get();
} catch (Exception $e) {
    die('ERROR: ' . $e->getMessage());
}
?>
<html>
  <head></head>
  <body>
    <h2>Search results for categories starting with 
      '<?php echo $prefix; ?>'</h2>
    <ol>
    <?php foreach ($result->query->allcategories->c as $c): ?>
      <li><a href="http://www.wikipedia.org/wiki/Category:
        <?php echo $c; ?>"><?php echo $c; ?></a></li>
    <?php endforeach; ?>
    </ol>
  </body>
</html>

Listing 2 first initializes the Zend Framework's autoloader and then loads the Zend_Rest_Client component. An instance of a Zend_Rest_Client object is created and initialized with the Wikipedia API service endpoint as constructor argument. Request parameters are then defined and added, and the request is transmitted to the API using the client object's get() method. The XML response from the server is automatically received and converted by Zend_Rest_Client into a set of SimpleXML objects, which you can access using standard object-property notation.

Figure 1 illustrates what the output of Listing 2 looks like.

Figure 1. A web page listing Wikipedia categories
Screen capture of a web page listing Wikipedia categories that begin with 'hollywood'

Notice the manner in which request parameters are passed to the server using Zend_Rest_Client. Each parameter is specified by calling a client method with the same name and by passing the value to the method as first argument. For example, to add the parameter action=query to the request, the script invokes $client->action('query'). You can read more about this in the Zend_Rest_Client documentation (see Resources for a link).

You can also retrieve a listing of pages within a category by altering the query to return a list of category members instead of categories. Obviously, you need to pass the category name to the API as input. Consider Listing 3, which does just this task.

Listing 3. Listing pages within a category
<?php
// load Zend classes
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Rest_Client');

// define category
$cat = 'Greek_legendary_creatures';

try {
  // initialize REST client
  $wikipedia = new Zend_Rest_Client('http://en.wikipedia.org/w/api.php');

  // set query parameters
  $wikipedia->action('query');
  $wikipedia->list('categorymembers');
  $wikipedia->cmtitle('Category:'.$cat);
  $wikipedia->cmlimit('30');
  $wikipedia->format('xml');

  // perform request
  // iterate over XML result set
  $result = $wikipedia->get();
} catch (Exception $e) {
    die('ERROR: ' . $e->getMessage());
}
?>
<html>
  <head></head>
  <body>
    <h2>Search results for pages in category 
      '<?php echo $cat; ?>'</h2>
    <ol>
    <?php foreach ($result->query->categorymembers->cm as $c): ?>
      <li><a href="http://www.wikipedia.org/wiki/
        <?php echo $c['title']; ?>">
        <?php echo $c['title']; ?></a></li>
    <?php endforeach; ?>
    </ol>
  </body>
</html>

Listing 3 specifies the name of a category and passes the name to the API using the cmtitle parameter. Notice also the cmlimit parameter, which specifies the number of results to return. As before, Zend_Rest_Client transmits the request and converts the XML response into SimpleXML objects, making it easy to parse and display the results of the query.

Figure 2 shows the output of Listing 3.

Figure 2. A web page listing Wikipedia pages in the selected category
Screen capture of a web page listing Wikipedia pages in the selected category, Greek_legendary_creatures

Performing full-text searches

Next, how about searching for pages that match a specific keyword? This task is easily accomplished with the same query described on the previous pages, except that in this case, you want to list search results instead of category members. Consider Listing 4, which illustrates the process.

Listing 4. Listing full-text search results
<?php
// load Zend classes
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Rest_Client');

// define search query
$query = 'michelangelo';

try {
  // initialize REST client
  $wikipedia = new Zend_Rest_Client('http://en.wikipedia.org/w/api.php');

  // set query parameters
  $wikipedia->action('query');
  $wikipedia->list('search');
  $wikipedia->srwhat('text');
  $wikipedia->format('xml');
  $wikipedia->srsearch($query);

  // perform request
  // iterate over XML result set
  $result = $wikipedia->get();
} catch (Exception $e) {
    die('ERROR: ' . $e->getMessage());
}
?>
<html>
  <head></head>
  <body>
    <h2>Search results for '<?php echo $query; ?>'</h2>
    <ol>
    <?php foreach ($result->query->search->p as $r): ?>
      <li><a href="http://www.wikipedia.org/wiki/
        <?php echo $r['title']; ?>">
        <?php echo $r['title']; ?></a> <br/>
      <small><?php echo $r['snippet']; ?></small></li>
    <?php endforeach; ?>
    </ol>
  </body>
</html>

Listing 4 uses the same query action seen previously, but the parameters are slightly different in this case. The list parameter specifies that this is a full-text search operation, while the srsearch parameter specifies the search keyword (in this case, "michelangelo"). It's also important to specify the srwhat parameter, which indicates whether the search should be performed on page titles or page text.

Each search result entry contains the page title, size, word count, namespace (more on this later), and a snippet of page content. You can then format and display this data as an HTML web page, as in Figure 3.

Figure 3. A web page listing Wikipedia search results
Screen capture of a web page listing Wikipedia search results for 'michelangelo'

Example application: Wikipedia search

In the real world, search keywords are not hard-coded into the script, but instead are entered by a user. Listing 5 improves Listing 4 to make it more interactive, allowing a user to enter a search term in the application and see Wikipedia pages matching that search term.

Listing 5. An interactive Wikipedia search tool
<html>
  <head></head>
  <body>
    <h2>Search</h2>
    <form method="post">
      Search: <input type="text" name="q" />
    </form>

    <?php
    // if form submitted
    if (isset($_POST['q'])) {
      // load Zend classes
      require_once 'Zend/Loader.php';
      Zend_Loader::loadClass('Zend_Rest_Client');

      try {
        // initialize REST client
        $wikipedia = new Zend_Rest_Client('http://en.wikipedia.org/w/api.php');

        // set query parameters
        $wikipedia->action('query');
        $wikipedia->list('search');
        $wikipedia->srwhat('text');
        $wikipedia->format('xml');
        $wikipedia->srsearch($_POST['q']);

        // perform request
        // iterate over XML result set
        $result = $wikipedia->get();
      } catch (Exception $e) {
          die('ERROR: ' . $e->getMessage());
      }
    ?>
    <h2>Search results for '<?php echo $_POST['q']; ?>'</h2>
    <ol>
    <?php foreach ($result->query->search->p as $r): ?>
      <li><a href="http://www.wikipedia.org/wiki/
      <?php echo $r['title']; ?>">
      <?php echo $r['title']; ?></a> <br/>
      <small><?php echo $r['snippet']; ?></small></li>
    <?php endforeach; ?>
    </ol>
    <?php 
    }
    ?>

  </body>
</html>

Nothing too complex in Listing 5: It simply performs an additional check for the user's input and passes that input to the srsearch parameter. Figure 4 illustrates the initial web form and the results of a search.

Figure 4. A web form for Wikipedia searches and the results
Screen capture of a web form for Wikipedia searches and the results for the phrase 'fruit fly'

Retrieving page content

The MediaWiki API also lets you access current or previous versions of page content by attaching the prop=revisions parameter to the query action. In this case, it's necessary to specify the title of the page to be returned. Consider Listing 6, which illustrates how this works.

Listing 6. Retrieving page content
<?php
// load Zend classes
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Rest_Client');

// define page title
$query = 'The A Team';

try {
  // initialize REST client
  $wikipedia = new Zend_Rest_Client('http://en.wikipedia.org/w/api.php');

  // set query parameters
  $wikipedia->action('query');
  $wikipedia->prop('revisions');
  $wikipedia->rvprop('content');
  $wikipedia->format('xml');
  $wikipedia->redirects('1');
  $wikipedia->titles($query);

  // perform request
  // get page content as XML
  $result = $wikipedia->get();
  $content = $result->query->pages->page->revisions->rev;
} catch (Exception $e) {
    die('ERROR: ' . $e->getMessage());
}
?>
<html>
  <head>
  </head>
  <body>
    <h2>Page result for '<?php echo $query; ?>'</h2>
    <div>
      <?php echo $content; ?>
      </script>
    </div>
  </body>
</html>

The query in Listing 6 is slightly different from the ones you've seen to date because it uses a property instead of a list. Properties are used to specify which pieces of information to retrieve for a set of pages. A number of different properties are available, including page metadata, revisions, links, images, templates, categories, and so on.

The query in Listing 6 specifies the revisions property and further uses the rvprop parameter to specify which properties to get for each revision—in this case, only the content of the revision. There's also an rvlimit parameter, which you can use to get multiple previous revisions; however, for the moment, you're only interested in the last (current) revision and so the query doesn't specify this parameter.

Figure 5 illustrates the output of Listing 6.

Figure 5. A web page displaying content in Wikitext
Screen capture of a web page displaying content in Wikitext as continuous, unformatted text string (topic: The A-Team)

As you can see from Figure 5, the output of Listing 6 is the content of the specified page in wiki markup (Wikitext). To use this data in a web application, however, you need to convert it from wiki markup to XHTML markup. A number of ready-made converters are available for this task, but one of the better ones is the PEAR Text_Wiki package, which can convert Wikitext to and from a variety of different formats.

To install it, simply issue the following command at your shell prompt:

shell> pear install Text_Wiki
shell> pear install Text_Wiki_Mediawiki

The PEAR installer now connects to the PEAR package server, downloads the packages, and installs them to the appropriate location on your system. If you prefer to install them manually, you can find download links in Resources.

After you install the packages, revise Listing 6 to use the Text_Wiki converter, as in Listing 7.

Listing 7. Retrieving page content and converting it to XHTML
<?php
// load Zend classes
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Rest_Client');

// load wikitext converter
require_once 'Text/Wiki.php';

// instantiate a Text_Wiki object from the given class
// and set it to use the Mediawiki adapter
$wiki = & Text_Wiki::factory('Mediawiki');

// set some rendering rules  
$wiki->setRenderConf('xhtml', 'wikilink', 'view_url', 
  'http://en.wikipedia.org/wiki/');
$wiki->setRenderConf('xhtml', 'wikilink', 'pages', false);
  
// define page title
$query = 'The A Team';

try {
  // initialize REST client
  $wikipedia = new Zend_Rest_Client('http://en.wikipedia.org/w/api.php');

  // set query parameters
  $wikipedia->action('query');
  $wikipedia->prop('revisions');
  $wikipedia->rvprop('content');
  $wikipedia->format('xml');
  $wikipedia->redirects('1');
  $wikipedia->titles($query);

  // perform request
  // get page content as XML
  $result = $wikipedia->get();
  $content = $result->query->pages->page->revisions->rev;
} catch (Exception $e) {
    die('ERROR: ' . $e->getMessage());
}
?>
<html>
  <head>
  </head>
  <body>
    <h2>Page result for '<?php echo $query; ?>'</h2>
    <div>
      <?php echo $wiki->transform($content, 'Xhtml'); ?>
      </script>
    </div>
  </body>
</html>

Listing 7 initializes a Text_Wiki object and sets it to use the Mediawiki adapter. It also specifies some parameters to use for XHTML conversion, including the default URL prefix to use for internal wiki links. Listing 7 then retrieves the specified page's content using the API and passes it through the Text_Wiki object's transform() method to convert it to XHTML. Figure 6 shows the revised output.

Figure 6. A web page displaying wiki content after conversion to XHTML
Screen capture of a web page displaying formatted wiki content after conversion to XHTML (topic: The A-Team

As Figure 6 shows, the Text_Wiki package does a reasonably good job of converting Wikitext into standard XHTML. It's not perfect, though, and doesn't account for all aspects of Wikitext markup (for example, it can't handle infoboxes at all). If you find that it doesn't do everything you need, consider replacing it with Steve Blinch's Wikitext parser (see Resources), which offers an alternative approach to Wikitext parsing and conversion.


Performing URL reference searches

An interesting aspect of Wikipedia's query API is that it allows you to search for pages referencing particular URLs. This ability is quite useful if, say, you want to see how often your website appears in Wikipedia entries.

To perform this query, you need to adjust the query to use the external URL list and pass along the specific URL that you're checking for. Consider Listing 8, which illustrates how you can do this.

Listing 8. Listing pages referencing a URL
<?php
// load Zend classes
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Rest_Client');

// define category prefix
$url = 'httpd.apache.org';

try {
  // initialize REST client
  $wikipedia = new Zend_Rest_Client('http://en.wikipedia.org/w/api.php');

  // set query parameters
  $wikipedia->action('query');
  $wikipedia->list('exturlusage');
  $wikipedia->euquery($url);
  $wikipedia->eulimit('30');
  $wikipedia->eunamespace('0');
  $wikipedia->format('xml');

  // perform request
  // iterate over XML result set
  $result = $wikipedia->get();
} catch (Exception $e) {
    die('ERROR: ' . $e->getMessage());
}
?>
<html>
  <head></head>
  <body>
    <h2>Search results for pages referencing URL 
      '<?php echo $url; ?>'</h2>
    <ol>
    <?php foreach ($result->query->exturlusage->eu as $r): ?>
      <li><a href="http://www.wikipedia.org/wiki/
      <?php echo $r['title']; ?>"><?php echo $r['title']; ?>
      </a></li>
    <?php endforeach; ?>
    </ol>
  </body>
</html>

In addition to the standard action and list parameters, Listing 8 also adds the euquery parameter, which specifies the URL to check for (in this case, the Apache website), and the eunamespace parameter, which specifies the wiki namespace to look in. Note that the URL must be specified without the "http://" protocol prefix. The results are parsed and processed in the usual manner, producing output that looks something like Figure 7.

Figure 7. A web page displaying pages referencing a specific URL
Screen capture of a web page displaying pages referencing a specific URL: httpd.apache.org

The namespace aspect of Listing 8 is worth explaining briefly. The MediaWiki API defines a number of different namespaces for the different types of content in a wiki. Each namespace is identified by a prefix attached to the page title. For example, a user page always has a "User:" namespace prefix, while a category page has a "Category:" namespace prefix.

Each namespace is also associated with an integer, which can be used to filter search queries. You can find a complete list of namespace integers and prefixes in the MediaWiki documentation (see Resources for a link), but here are the ones that you use most often:

  • 0: The default namespace for content pages
  • 1: The namespace for talk pages
  • 2: The namespace for user pages
  • 6: The namespace for files
  • 14: The namespace for category pages

From the above list, it should be clear that Listing 8 is restricting the query only to content pages through the eunamespace parameter. Removing this constraint returns a larger number of results, including user pages and talk pages containing the specified URL.


Adding and editing pages

All the previous listings in this article focused on the API's query action, illustrating how you can use it to retrieve different types of data from the content repository. The API, however, also supports a number of other methods, including the ability to create new pages or edit existing pages. To accomplish these tasks, call the API's edit action and pass it the title of the page to be edited or created, together with the content for the page or section.

Every edit operation must be accompanied by a token, which ensures the validity of the user request and protects against CSRF attacks. Tokens typically consist of an alphanumeric string, ending with a special +\ sequence. For anonymous users, tokens consist only of the +\ sequence.

The token must be attached with the edit request, as in Listing 9.

Listing 9. Editing pages
<?php
// load Zend classes
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Rest_Client');

try {
  // initialize REST client
  $wikipedia = new Zend_Rest_Client('http://en.wikipedia.org/w/api.php');

  // set query parameters
  $wikipedia->action('edit');
  $wikipedia->title('Wikipedia:Sandbox');
  $wikipedia->section('new');
  $wikipedia->summary('My Section');
  $wikipedia->text('Some text');
  $wikipedia->token('+\\');
  
  // POST page data 
  $wikipedia->post();
} catch (Exception $e) {
}
?>

Listing 9 introduces a number of new request arguments.

  • The title argument specifies the page to be edited. In this case, the edit is being performed on the special Wikipedia sandbox page, which is intended specifically for experimentation and testing and is automatically cleared at regular intervals.
  • The section argument specifies the section number to be edited. Using the special keyword "new" adds a new section. Omitting this argument replaces the entire page.
  • The summary argument specifies the title of the section, when creating a new section.
  • The text argument contains the content of the section or page.
  • The token argument specifies the token for the edit operation.

Notice also that unlike previous listings, an edit request must be transmitted using POST and not GET. That's why Listing 9 specifically uses the Zend_Rest_Client's post() method to transmit the request. Because the Wikipedia API doesn't return an XML response to a POST, Zend_Rest_Client raises a SimpleXML exception when it reads the response. That's why the listing is written to catch the exception but doesn't actually do anything with it. An alternative approach here might be to use Zend_Http_Client and manually create the POST packet.

After the request is completed, you can see your change on the target page, and your system's IP address (for anonymous users) or your username (for authenticated users) appears in the page's revision history. A revision history entry includes a date-time stamp, IP address or username, type of edit indicator, and size in bytes. Figure 8 has an example.

Figure 8. The revision history of a Wikipedia page, showing edits performed through the API
Screen capture of the revision history of a Wikipedia page, showing edits performed through the API

Conclusion

Over the last few pages, this article gave you a crash course in how to use the MediaWiki API to retrieve and integrate information from Wikipedia with your PHP web application. It also briefly examined some of the unique aspects of this API, such as namespaces, properties, and lists, and demonstrated how you can use the API not just to read data from the wiki, but also to write data back to it.

The information presented in this article is just the tip of the iceberg. The query module discussed over the last few pages is extremely powerful and allows you to access many more facets of wiki content, including images, files, user data, and page revision data. And while the query module is undoubtedly the one that you'll use most frequently, additional existing modules allow you to calculate statistics such as user clicks, user edits, and user registrations; submit article feedback; return user profile information; roll back page edits; upload files; manipulate user watchlists; and much more.

As the examples in this article illustrate, the MediaWiki API offers a flexible tool for developers looking to build creative new applications around the content in Wikipedia or any other MediaWiki-based wiki. Play with it sometime, and see what you think.

Resources

Learn

Get products and technologies

Discuss

Comments

developerWorks: Sign in

Required fields are indicated with an asterisk (*).


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name



The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


All information submitted is secure.

Dig deeper into XML on developerWorks


static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=XML, Open source, Web development
ArticleID=658352
ArticleTitle=Hook into Wikipedia information using PHP and the MediaWiki API
publish-date=05172011