Sending SMS
Deprecated API
Although, this API is still supported, we suggest using a more modern and feature-rich Omnichannel API for sending SMS messages.
Sending SMS to the handset using Messente HTTP SMS Messaging API
You can deliver SMS to any handset using Messente's HTTP SMS 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 endpoint:
https://api2.messente.com/send_sms
Backup API endpoint:
https://api3.messente.com/send_sms
Examples
- Python
- PHP
- Java
import messente
api = messente.Messente(username="YOUR_API_USERNAME", password="YOUR_API_PASSWORD")
# 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)
// Messente API username and password
define('MESSENTE_API_USERNAME', 'YOUR_API_USERNAME');
define('MESSENTE_API_PASSWORD', 'YOUR_API_PASSWORD');
define('MESSENTE_SMS_DLR_URL', 'https://myservice.com/dlr/messente/239d8/');
// 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);
if ($resp == 'OK') {
echo 'Message sent successfully with MessageID '.$code;
} else {
echo 'Sending message failed with error code '.$code;
}
public class SendSmsSimpleExample {
public static final String API_USERNAME = "YOUR_API_USERNAME";
public static final String API_PASSWORD = "YOUR_API_PASSWORD";
public static final String SMS_SENDER_ID = "YOUR_SENDER_ID";
public static final String SMS_RECIPIENT = "+3721234567";
public static final String SMS_TEXT = "Hey! Check out messente.com, it's awesome!";
public static void main(String[] args) {
// Create Messente client
Messente messente = new Messente(API_USERNAME, API_PASSWORD);
// Create response object
MessenteResponse response = null;
try {
// Send SMS
response = messente.sendSMS(SMS_SENDER_ID, SMS_RECIPIENT, SMS_TEXT);
// Checking the response status
if (response.isSuccess()) {
// Get Messente server full response
System.out.println("Server response: " + response.getRawResponse());
//Get unique message ID part of the response(can be used for retrieving message delivery status later)
System.out.println("SMS unique ID: " + response.getResult());
} else {
// In case of failure get failure message
throw new RuntimeException(response.getResponseMessage());
}
} catch (Exception e) {
System.err.println(e.getMessage());
throw new RuntimeException("Failed to send SMS! " + e.getMessage());
}
}
}
API Reference
For a full list of response codes and HTTPI API request parameters, refer to the API Reference.
Libraries
Messente has HTTP API libraries for various languages including PHP, Python, Java and C#. Check out the Messente Libraries section in our documentation.