Messente avatar logo

Sending SMS

Sending SMS to the handset using Messente HTTP SMS Messaging API

You can deliver SMS to any handset using Messente's HTTP API and later use the returned MessageID to check Delivery Report for this message.

You can send SMS to any number by making a HTTP GET or HTTP POST call to Messente API.

Messaging API endpoints
Main API endpointhttps://api2.messente.com/send_sms/
Backup API endpointhttps://api3.messente.com/send_sms/

Examples

// Messente API username and password
define('MESSENTE_API_USERNAME', '34edae9e1a5e563f5eced203f09f229e');
define('MESSENTE_API_PASSWORD', '385c064fc6d687c01e529348d3685cb1');
define('MESSENTE_SMS_DLR_URL', 'https://myservice.com/dlr/messente/239d8/');

// Initial message statuses
$status = NULL;
$MessageID = NULL;
$ErrorCode = NULL;

// Make HTTP call to Messente API
$url = 'https://api2.messente.com/send_sms/?'.
http_build_query(
  array(
    'username' => MESSENTE_API_USERNAME,
    'password' => MESSENTE_API_PASSWORD,
    'from' => 'MyDelivery',
    'to' => '+44000000000',
    'text' => 'Your parcel will be delivered at 10AM',
    'dlr-url' => MESSENTE_SMS_DLR_URL
  )
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);

$response = curl_exec($ch);
list($resp, $code) = explode(' ', $response);

// Check if the sms delivery request was successful
if ($resp == 'OK') {
  $status = TRUE;
  $MessageID = $code;
} else {
  $status = FALSE;
  $ErrorCode = $code;
}

if ($status == TRUE) {
  echo 'Message sent successfully with MessageID '.$MessageID;
  // TODO: Save the message to database and store MessageID
  // INSERT INTO messages (from, to, text, msgid, sent_time)
  // VALUES (:from, :to, :text, :MessageID, NOW())
} else {
  echo 'Sending message failed with error code '.$ErrorCode;
}
            
import messente

# Initialize Messente API library
api = messente.Messente(
    username="34edae9e1a5e563f5eced203f09f229e",
    password="385c064fc6d687c01e529348d3685cb1"
) # Send SMS response = api.sms.send({ "from": "MyDelivery", "to": "+44000000000", "text": "Your parcel will be delivered at 10AM" })

if response.is_ok():
print("Message sent:", response.get_sms_id())
else:
print("Message failed:", response.error_code)

API Reference

For full list of response codes and HTTPI API request parameters, refer to the API Reference - Sending SMS.

Libraries

Messente has HTTP API libraries for various languages including PHP, Python, Java and C#. Check out the Messente Libraries section in our documentation.