Source for file
examples.guifi_api.device.php
Documentation is available at examples.guifi_api.device.php
-
-
// The source code packaged with this file is Free Software, Copyright (C) 2005 by
-
// Eduard Duran <eduard.duran at iglu.cat>.
-
// It's licensed under the AFFERO GENERAL PUBLIC LICENSE unless stated otherwise.
-
// You can get copies of the licenses here:
-
// http://www.affero.org/oagpl.html
-
// AFFERO GENERAL PUBLIC LICENSE is also included in the file called "LICENSE.txt".
-
-
require ( 'guifi_api.php' );
-
-
-
* Configuration of authentication against guifi.net
-
-
-
-
-
-
-
-
$gapi = new guifiAPI( $username, $password );
-
-
$action = $_GET['action'];
-
-
-
-
-
-
$mac = 'AB:CD:EF:AB:CD:EE';
-
-
-
$device['nick'] = "DispositiuTroncal3";
-
$device['notification'] = 'name@example.com';
-
$device['comment'] = "Aquest dispositiu servirà per extendre la troncal";
-
$device['status'] = 'Planned';
-
$device['graph_server'] = 15902;
-
$device['model_id'] = 27; // Supertrasto RB600 guifi.net
-
$device['firmware'] = "RouterOSv3.x";
-
-
$added = $gapi->addDevice($node_id, $type, $mac, $device );
-
-
-
echo "Device created correctly!!<br />\n<br />\nThe identificator of the new device is: device_id = <strong>$added->device_id</strong>";
-
-
echo "There was an error adding the device.<br />\n";
-
echo $gapi->getErrorsStr();
-
-
-
-
-
-
-
$device['nick'] = "DispositiuTroncal3";
-
$device['notification'] = 'name@example.com';
-
$device['comment'] = "Aquest dispositiu servirà per extendre la troncal. I ara funciona!";
-
$device['status'] = 'Working';
-
$device['model_id'] = 27; // Supertrasto RB600 guifi.net
-
$device['firmware'] = "RouterOSv3.x";
-
-
$updated = $gapi->updateDevice( $device_id, $device );
-
-
echo "Device <strong>$device_id</strong> was updated correctly.<br />\n<br />\n";
-
-
echo "There was an error updating the device.<br />\n";
-
echo $gapi->getErrorsStr();
-
-
-
-
-
-
$removed = $gapi->removeDevice( $device_id );
-
-
echo "Device <strong>$device_id</strong> removed correctly.<br />\n<br />\n";
-
-
echo "There was an error deleting the device.<br />\n";
-
echo $gapi->getErrorsStr();
-
-
-
-
-
|