PHP

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?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";
?>