Calling the WoRMS webservice from PHP4

This tutorial assumes you are using any webserver with PHP4 installed and working properly.

Step 1: Download the NuSOAP Library

Download the latest version 0.9.5 (nusoap-0.9.5.zip) from SourceForge.
Exctract the package in the directory "nusoap"

Step 2: Paste the following code in a .php file (this is just an example)
 $client = new SoapClient("http://marinespecies.org/aphia.php?p=soap");
 $AphiaID = $client->call("getAphiaID", array("scientificname" => "solea solea"));
 $taxon  = $client->call("getAphiaRecordByID", array("AphiaID" => $AphiaID));
 echo "<b>AphiaID</b>: ".$taxon["AphiaID"]."<br />\n";
 echo "<b>Displayname</b>: ".$taxon["scientificname"]." ".$taxon["authority"]."<br />\n";
 echo "<b>URL</b>: ".$taxon["url"]."<br />\n";
 echo "<b>Accepted name</b>: ".$taxon["valid_name"]." ".$taxon["valid_authority"]."<br />\n";
 $class  = $client->call("getAphiaClassificationByID", array("AphiaID" => $AphiaID));
 echo "<b>Classification</b>: ";

 function show_classification($class){
  echo $class["scientificname"]." (".$class["rank"].") > ";
  if ($class["child"]) show_classification($class["child"]);

Step 3: Run the script

It should return something like this:
AphiaID: 127160
Displayname: Solea solea (Linnaeus, 1758)
URL: http://marinespecies.org/aphia.php?p=taxdetails&id=127160
Accepted name: Solea solea (Linnaeus, 1758)
Classification: Animalia (Kingdom) > Chordata (Phylum) > Vertebrata (Subphylum) > Gnathostomata (Superclass) > Pisces (Superclass) > Actinopterygii (Class) > Pleuronectiformes (Order) > Soleidae (Family) > Solea (Genus) > Solea solea (Species) >

Download this example.