PHP script: Send SMS with the HTTP API

This PHP script can be used to send SMS messages from a web server to the HTTP API of Diafaan SMS Server.

<?php 
/*
PHP script to send SMS messages with the HTTP API of Diafaan SMS Server
*/
 
echo SendMessage('localhost', '9710', 'admin', 'password', '+32xxxxxxxxxx', 'My text message');
 
function SendMessage($host, $port, $userName, $password, $number, $message)
{
 
    /* Create the HTTP API query string */
    $query = 'http://'.$host.':'.$port;
    $query .= '/http/send-message/';
    $query .= '?username='.urlencode($userName);
    $query .= '&password='.urlencode($password);
    $query .= '&to='.urlencode($number);
    $query .= '&message='.urlencode($message);
     
    /* Send the HTTP API request and return the response */
    return file_get_contents($query);  
}
 
?>