Skip to main content

PHP

The example below works for PHP 4 >= 4.3.0, PHP 5, PHP 7.

 <?php function send_replypath_sms($dest, $message) {
// Set your Spirius account username and password here $username = "Username";
$password = "Password";
$context = stream_context_create(array( "http" => array( "method" => "GET", "header" => "Authorization: Basic ". base64_encode($username.':'.$password). "\r\n". "Accept: application/json\r\n". "Connection: close\r\n", "protocol_version" => 1.1, "timeout" => 10 )));
$enc_dest = urlencode($dest);
$enc_mess = urlencode($message);
$response = file_get_contents( "https://srp.spirius.com:55001/v1/replypath/sendsms/$enc_dest/$enc_mess", false, $context );
if (!strstr($http_response_header[0],"200 OK")) {
return $http_response_header[0];
}
return $response;
}
echo send_replypath_sms ("+46123456789", "Hello world") . "\n";
?>