// Abbreviated name of the node
     $node['body'] = "Aquest és el meu node, situat a la Plaça Major, 34, al nucli antic del poble.";
     // Body of the node
     $node['zone_description'] = "Situat al nucli antic del poble, al costat de la carnisseria";
     // Description of the zone
     $node['notification'] = "*****@*****.**";
     $node['lat'] = '41.54301946112854';
     // Latitude of the node
     $node['lon'] = '1.5803146362304688';
     // Longitude of the node
     $node['elevation'] = 30;
     // 30 metres high
     $node['stable'] = 'Yes';
     $node['graph_server'] = 15902;
     $node['status'] = 'Planned';
     $added = $gapi->addNode($title, $zone_id, $lat, $lon, $node);
     if ($added) {
         echo "Node created correctly!!<br />\n<br />\nThe identificator of the new node is: node_id = <strong>{$added->node_id}</strong>";
     } else {
         echo "There was an error adding the node.<br />\n";
         echo $gapi->getErrorsStr();
     }
     break;
 case 'update':
     $node_id = 27185;
     $node = array();
     $zone['title'] = "Plaça Major, 34, 2n pis";
     $zone['nick'] = "PlacaMajor34";
     $node['body'] = "Aquest és el meu node, situat a la Plaça Major, 34, al nucli antic del poble. Ara està actualitzat i plenament operatiu!";
     // Body of the node
     $node['elevation'] = 40;
}
if (!empty($_GET['m'])) {
    $messages[1] = "Hi ha hagut un error al crear el teu node. Revisa bé les dades introduïdes!";
    if (isset($messages[$_GET['m']])) {
        $message = $messages[$_GET['m']];
    }
}
if (!empty($_POST)) {
    $username = $_POST['username'];
    $password = $_POST['password'];
    $title = $_POST['title'];
    $zone_id = $_POST['zone_id'];
    $lat = $_POST['lat'];
    $lon = $_POST['lon'];
    $gapi = new guifiAPI($username, $password);
    $node = $gapi->addNode($title, $zone_id, $lat, $lon);
    if (!empty($node->node_id)) {
        header("Location: examples.guifi_api.simple_user.step2.php?node_id={$node->node_id}");
        die;
    } else {
        $message = "No s'ha pogut crear el teu node. Revisa bé les dades introduïdes!";
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Client PHP per l'API de guifi.net</title>
<script src="http://jqueryjs.googlecode.com/files/jquery-1.3.2.min.js"></script>
<link rel="stylesheet" type="text/css" href="style.css" />