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

Source for file examples.guifi_api.device.php

Documentation is available at examples.guifi_api.device.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.         $node_id 27192;
  27.         $type 'radio';
  28.         $mac 'AB:CD:EF:AB:CD:EE';
  29.         
  30.         $device array();
  31.         $device['nick'"DispositiuTroncal3";
  32.         $device['notification''name@example.com';
  33.         $device['comment'"Aquest dispositiu servirà per extendre la troncal";
  34.         $device['status''Planned';
  35.         $device['graph_server'15902;
  36.         $device['model_id'27// Supertrasto RB600 guifi.net
  37.         $device['firmware'"RouterOSv3.x";
  38.         
  39.         $added $gapi->addDevice($node_id$type$mac$device );
  40.         
  41.         if$added {
  42.             echo "Device created correctly!!<br />\n<br />\nThe identificator of the new device is: device_id = <strong>$added->device_id</strong>";
  43.         else {
  44.             echo "There was an error adding the device.<br />\n";
  45.             echo $gapi->getErrorsStr();
  46.         }
  47.         break;
  48.     case 'update':
  49.         $device_id 19534;
  50.         
  51.         $device array();
  52.         $device['nick'"DispositiuTroncal3";
  53.         $device['notification''name@example.com';
  54.         $device['comment'"Aquest dispositiu servirà per extendre la troncal. I ara funciona!";
  55.         $device['status''Working';
  56.         $device['model_id'27// Supertrasto RB600 guifi.net
  57.         $device['firmware'"RouterOSv3.x";
  58.         
  59.         $updated $gapi->updateDevice$device_id$device );
  60.         if$updated {
  61.             echo "Device <strong>$device_id</strong> was updated correctly.<br />\n<br />\n";
  62.         else {
  63.             echo "There was an error updating the device.<br />\n";
  64.             echo $gapi->getErrorsStr();
  65.         }
  66.         break;
  67.     case 'delete':
  68.         $device_id 19534;
  69.         
  70.         $removed $gapi->removeDevice$device_id );
  71.         if$removed {
  72.             echo "Device <strong>$device_id</strong> removed correctly.<br />\n<br />\n";
  73.         else {
  74.             echo "There was an error deleting the device.<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