Dovado TINY Manuel d'utilisateur Page 25

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 46
  • Table des matières
  • DEPANNAGE
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 24
The M obile Cho ic e for y our B r o adba n d Inte rnet
API 25
© 2014 Dovado FZ-LLC
Since there can only be one instance of the API running on the Router, a session that has been
inactive for more than 60 seconds will be dropped in favor of a new session.
4.9.1 Example code
API example code for different platforms are available on http://www.dovado.mobi/
4.9.1.1 PHP
Below is a sample php script that will connect to the router and then send a SMS via the API
<?php
error_reporting(E_ALL);
echo "Code example on how to send a SMS via the Dovado router API\n";
/* The following variables are set
$username= your username to the router with API access
$password= your password for the above username
$ipaddress = ipaddress of your router
$api_port = 6435;
$smsnr = Number to send SMS to
$smstxt = Message content for your SMS
*/
$username = "admin";
$password = "password";
$api_port = 6435;
$ipaddress = ('192.168.0.1');
$smsnr = "Enter your phonenumber in international format (4670000000)";
$smstxt = "Enter Text Here";
$readbuf = '';
/* Function to wait for >> answers */
function respons_wait($insocket)
{
do {
$readbuf = socket_read($insocket, 4096, PHP_BINARY_READ) ;
}while (strpos($readbuf,'>>') === false);
$readbuf = '';
}
/* Create a TCP/IP socket. */
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
if ($socket === false) {
echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "\n";
} else {
echo "OK.\n";
}
echo "Attempting to connect to '$ipaddress' on port '$api_port'...";
$result = socket_connect($socket, $ipaddress, $api_port);
if ($result === false) {
echo "socket_connect() failed.\nReason: ($result) " . socket_strerror(socket_last_error($socket)) . "\n";
} else {
echo "\nConnected to router\n";
}
respons_wait($socket);
/* Sending username to the API */
echo "Sending User Name...\n";
socket_write($socket, "user $username \r\n", strlen($username)+8);
echo "OK.\n";
respons_wait($socket);
/* Sending password to the API */
echo "Sending password...\n";
socket_write($socket, "pass $password \r\n", strlen($password)+8);
echo "OK.\n";
respons_wait($socket);
/* Setting up destination SMS number */
Vue de la page 24
1 2 ... 20 21 22 23 24 25 26 27 28 29 30 ... 45 46

Commentaires sur ces manuels

Pas de commentaire