PHP

There are several ways to send SMS messages with our API using PHP. The following 2 are the most commonly used.

1. php_curl Library

This assumes that the php_curl library is enabled on the server hosting your website, otherwise contact your host to enable it.

<?php
try {
$serverUrl = "http://aspsmsapi.com/http/sendsms.aspx?"; // URL de base
$dest = "233xxxxxx"; // MSIDSN (Number of the recipient in the International format)
$username = "223xxxxxx"; // Your username
$apikey = "xxxxxx"; // APIKEY
$msg = "Test Message PHP"; // Message content
$senderid = "ASPSMS"; // Sender ID
$authmode = "http"; // Mandotory. Do not change. Case sensitive
// CURL_INIT
$ch = curl_init($serverUrl);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_POSTFIELDS,"dest=$dest&username=$username&apikey=$apikey&senderid=$senderid&msg=$msg&authmode=$authmode");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
echo $output = curl_exec($ch); // Display server result
curl_close($ch);

}catch(Exception $ex) {
echo $ex;
}
?>

2. file_get_content()  method

In most cases, this method will work on any type of servers without special configuration. If not, contact your hosting provider.

<?php
// Definition of parameters (CHANGE please)
$dest = "233xxxxxx,233xxxxxx,233xxxxxx"; // MSIDSN (Number of the recipient in the International format)
$username = "233xxxxxx"; // Your Username
$apikey = "xxxxxx"; // ApiKey
$msg = "Test Message API PHP"; // Message content
$senderid = "ASPSMS"; // Sender ID
$authmode = "http"; // Mandatory (DO NOT CHANGE - Case Sensitive)
// Assembly Parameters (DO NOT CHANGE)
$params = array (
'username' => $username,
'apikey' => $apikey,
'senderid' => $senderid,
'msg' => $msg,
'dest' => $dest,
'authmode' => $authmode,
);
// Application Construction (DO NOT CHANGE)
$query = http_build_query ($params);
// Creating an HTTP request
$contextData = array (
'method' => 'POST',
'header' => "Connection: close\r\n".
"Content-Type: application/x-www-form-urlencoded\r\n".
"Content-Length: ".strlen($query)."\r\n",
'content'=> $query );
// Final Assembly Parameters (DO NOT CHANGE)
$context = stream_context_create (array ( 'http' => $contextData ));
// Execute query and display server response
echo $result = file_get_contents('http://aspsmsapi.com/http/sendsms.aspx',false,$context);
?>
The new disc fly replica watches collection series ladies watch incorporates many replica watch modern and fashionable aesthetic elements in the classic design. Available in 39mm and 36mm sizes, the watch is fake replica watches available in a variety of materials with replica rolex a rich palette of colours.