default
[ class tree: default ] [ index: default ] [ all elements ]

Source for file examples.guifi_api.node.php

Documentation is available at examples.guifi_api.node.php

  1. <?php
  2. // The source code packaged with this file is Free Software, Copyright (C) 2005 by
  3. // Eduard Duran <eduard.duran at iglu.cat>.
  4. // It's licensed under the AFFERO GENERAL PUBLIC LICENSE unless stated otherwise.
  5. // You can get copies of the licenses here:
  6. //         http://www.affero.org/oagpl.html
  7. // AFFERO GENERAL PUBLIC LICENSE is also included in the file called "LICENSE.txt".
  8.  
  9. require 'guifi_api.php' );
  10.  
  11. /**
  12.  * Configuration of authentication against guifi.net
  13.  */
  14. $username "";
  15. $password "";
  16.  
  17. /**
  18.  * Code from here!
  19.  */
  20. $gapi new guifiAPI$username$password );
  21.  
  22. $action $_GET['action'];
  23.  
  24. switch$action {
  25.     case 'add':
  26.         $title "Plaça Major, 34";
  27.         $zone_id 27182;
  28.         $lat '42.187065853813635';
  29.         $lon '2.0233726501464844';
  30.         $node array();
  31.         $node['nick''PlacaMajor34'// Abbreviated name of the node
  32.         $node['body'"Aquest és el meu node, situat a la Plaça Major, 34, al nucli antic del poble."// Body of the node
  33.         $node['zone_description'"Situat al nucli antic del poble, al costat de la carnisseria"// Description of the zone
  34.         $node['notification'"email@example.com";
  35.         $node['lat''41.54301946112854'// Latitude of the node
  36.         $node['lon''1.5803146362304688'// Longitude of the node
  37.         $node['elevation'30// 30 metres high
  38.         $node['stable''Yes';
  39.         $node['graph_server'15902;
  40.         $node['status''Planned';
  41.  
  42.         $added $gapi->addNode$title$zone_id$lat$lon$node );
  43.         if$added {
  44.             echo "Node created correctly!!<br />\n<br />\nThe identificator of the new node is: node_id = <strong>$added->node_id</strong>";
  45.         else {
  46.             echo "There was an error adding the node.<br />\n";
  47.             echo $gapi->getErrorsStr();
  48.         }
  49.         break;
  50.     case 'update':
  51.         $node_id 27185;
  52.         
  53.         $node array();
  54.         $zone['title'"Plaça Major, 34, 2n pis";
  55.         $zone['nick'"PlacaMajor34";
  56.         $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
  57.         $node['elevation'40// 30 metres high
  58.         $node['status''Working';
  59.         
  60.         $updated $gapi->updateNode$node_id$node );
  61.         if$updated {
  62.             echo "Node <strong>$node_id</strong> was updated correctly.<br />\n<br />\n";
  63.         else {
  64.             echo "There was an error updating the node.<br />\n";
  65.             echo $gapi->getErrorsStr();
  66.         }
  67.         break;
  68.     case 'delete':
  69.         $node_id 27185;
  70.         $removed $gapi->removeNode$node_id );
  71.         if$removed {
  72.             echo "Node <strong>$node_id</strong> removed correctly.<br />\n<br />\n";
  73.         else {
  74.             echo "There was an error deleting the node.<br />\n";
  75.             echo $gapi->getErrorsStr();
  76.         }
  77.         break;
  78. }
  79.  
  80. ?>

Documentation generated on Sun, 10 Jan 2010 21:02:49 +0100 by phpDocumentor 1.4.3