The use of text messaging has become widespread in many industries across the world, to the point where a lot of businesses have integrated SMS to notify their customers about offers, events, or coupons directly through their mobile devices.

If you want to send out SMS messages in bulk, you’ll need to use an SMS API and a web programming language such as PHP. If you can create a simple webpage or make an HTTP request with PHP, you’ll be able to integrate Messente’s PHP SMS API. This article gives an overview of the API and explains how the integration works.

What is PHP?

PHP is an acronym for "Hypertext Preprocessor", it's an open-source general-purpose scripting language that can be embedded into an HTML.

PHP by itself has little to no functionality with SMS, but with the use of an SMS API, it can be fully taken advantage of.

About Messente’s SMS API

Messente’s SMS API connects your application with telecoms networks around the globe. It can be used for both marketing and transactional messages and is ideal for sending SMS at scale.

Messente is an SMS API and an SMS gateway provider, meaning it allows your business to send and receive SMS messages without needing a mobile phone.

How does SMS travel from a web application to a mobile phone?

  • The message is first composed using a web application such as Messente that's stored and executed on an HTTP server, the message is then sent through the internet as an 'email message'.

  • The 'email message' is then received by the Short Message Service Gateway or SMS gateway, which converts the 'email message' into an SMS message.

  • The SMS is then sent to the SMSC (Short Message Service Center). The purpose of an SMSC is to route data to specific mobile devices.

  • The SMS message is then delivered to the recipient over the wireless network.

Our latest version of this API works to send messages across three other channels: Viber, WhatsApp and Telegram. It’s useful if you want to adopt an omnichannel approach to communications or need to use one of these channels as a fallback should a recipient not be signed up to SMS notifications. As a RESTful API, it has five main functions across all supported channels, allowing you to:

  • Send SMS messages to customers.

  • Receive message delivery reports.

  • Receive messages from customers.

  • Schedule messages.

  • Send SMS messages with other channels as a fallback.

How the API works

Once integrated with your application, a call is made to the API each time you want to send an SMS. Messente’s system is the intermediary that translates and transfers the message to a mobile network operator for onward delivery to the recipient. Through the API, you’ll receive message delivery status updates back to your application.

How omnichannel SMS API works

Messente’s API libraries

The SMS API is supported by coding libraries for PHP, Python, Node, Ruby and Java. For the purpose of this article, we’ll be focusing on integrating the API using PHP.

How to integrate Messente’s SMS API in PHP

Integration should take no longer than a day. It can be done in just a few steps, which we’ve briefly outlined below. Do also check out our Omnichannel Quickstart guide, which explains how to integrate the API in more detail.

Step 1: Create your Messente account

You’ll need to signup to Messente to get started (no credit card details required). You’ll receive some free credits to your account to help you try the system out and send your first few text messages.

Step 2: Create a sender ID

Next, apply for a sender ID. This can be a phone number, a shortcode or a brand name. The quickest option is to use your own phone number (which you’ll need to verify through an SMS to your handset). You’ll see prompts about the sender ID as soon as you log into the dashboard.

Step 3: Create an API key

Only create an API key once you’ve selected your sender ID; otherwise, your code will produce errors when you come to send SMS messages. To do this, click on Developers from the left-hand menu in the Messente dashboard. Then click on Create New API Key.

Creating an API key for PHP SMS API

Step 4: Install our PHP code library

The easiest way to start using the API is by downloading and installing Messente’s PHP code library into your application. This can be done using Composer, a dependency manager for PHP. Using the code library means you don’t have to reinvent the wheel and write your own code from scratch.

PHP SMS API tutorial: Sending your first text

Before you can start sending SMS messages, you’ll need to configure the PHP code with your API key details (username and password). You’ll also need to replace the relevant variables with your sender name and recipient phone number.

In our Quickstart guide, we’ve provided a snippet of PHP code that you can copy and paste into your software to enable you to send a single SMS. It looks like this:

Sending the first SMS with PHP SMS API

The SMS message content can contain up to 160 characters (using the GSM-7 character encoding standard). When you’ve finished configuring the PHP code, simply run the script to send the SMS message to the number specified. To see the individual request parameters for sending an SMS, check out the detailed API reference.

Messente’s other PHP SMS API features

To receive delivery reports for your SMS messages, you’ll need to add a callback URL to your message. Messente uses the callback URL to provide status updates to you. Use our code snippet to try this feature out.

To set up the channel fallback option, you’ll need to specify a fallback priority in the outgoing request. Once set up, Messente selects an alternative channel in the priority order you’ve chosen, should the recipient not be available via SMS. There’s a code snippet example in the API Quickstart guide that you can copy and paste to help with this.

Send bulk SMS messages with Messente’s PHP SMS API

Messente’s SMS API has been designed with simplicity in mind so that anyone with a basic knowledge of web development or making HTTP requests can use its functionality.

Once you’ve created your Messente account and received your API key, you can get started with integrating the SMS API into your software with PHP and eventually send SMS using PHP. The easiest way is to install our PHP coding library. It ensures authentication, request validation and response handling are taken care of.

Creating a Messente account is free - signup here.