PHP SMS API

Ozeki SMS Gateway makes it possible for php developers to use php sms api for text message sending and receiving on their web page to mobile phone.

How to send sms from website using php

There are two basic options to choose from if you wish to send SMS messages from a website running on PHP. You can use HTTP requests to pass SMS messages directly to the SMS gateway or you can save your outgoing messages into a database and let the SMS gateway pick up the messages from there. Both options have advantages and disadvantages. This guide helps you get started by giving you information on which option is more suitable for you.

How to send/receive SMS from PHP through a database ( )

If your PHP website uses a database, such as MySQL, using this same database for sending and receiving is a good option. In this setup two database tables will be created; one called ozekimessageout will be used for sending SMS, and another called ozekimessaging willb e used for receiving SMS.

ozeki sms gateways database and php sms api two way communication method
Figure 1 - Ozeki SMS Gateway's Database + PHP SMS solution (Two-way communication method)

Advantages of sending SMS from a Database

This option has several advantages. First it will be very easy for you to send a message by simply creating a database record in the ozekimessageout database table. All you have to do is simply execute an SQL INSERT command. After the message is inserted into the database table it will be picked up by Ozeki and it will be sent to the mobile network.

The biggest advantage to this option is that Ozeki will update the status of your outgoing SMS. This means that when the message is sent to the mobile network, or when a delivery report comes in after the SMS reaches the recipient handset, Ozeki will update the status field of the SMS to 'submitted to network' or 'delivered to handset' status. It will also set the appropriate timestamp for these events. It is very convenient to have all these information in a database table.

Incoming messages will also be easy to process, as they will be automatically inserted into a database table by Ozeki SMS Gateway. To read new messages you simply do a SELECT on the ozekimessagein table. You can freely add SQL columns to this database table to store processing related information.

Disadvantages of sending SMS from a Database

If you use a database as a method of comnunication between your SMS gateway and your PHP website, you must take into account that some delays in sending SMS messages will occur. The SMS gateway checks the outgoing database table periodically (the default poll interval is 5 seconds). If a message is inserted, it will take a few seconds for it to be picked up by the SMS gateway for delivery.

Where can I find setup instructions for sending SMS from a Database?

The following page contains a video tutorial and detailed step by step instructions on how to setup SMS message on a PHP website with MySQL.

How to send/receive SMS from PHP through the HTTP API ()

PHP gives you the option to issue HTTP requests. Since the Ozeki SMS gateway has a great http sms api, you can send SMS messages by simply forming an URL and calling it using one of the built in PHP http download methods. Using an HTTP request you can both send and SMS and you can also receive SMS messages.

ozeki sms gateways http api and php sms solution two way communication method
Figure 2 - Ozeki SMS Gateway's HTTP API + PHP SMS solution (Two-way communication method)

Advantages of sending SMS using the HTTP SMS API

One of the biggest advantages to using the HTTP API is speed. If you send an SMS using an HTTP request, it will immediately get to the SMS gateway without any delays. If you use a database table, it will spend a few seconds in the database table. Note however, that this is only true if you only send out a few messages per minute. The HTTP request require quite a lot of resources in both network bandwidth and processing power. This means if you send a message in bulk, it is not a good choice. If you send a single SMS, it will get there a few seconds faster. If you wish to send more than 10 messages, it is much better to use a database for transfer, since these messages can be picked up by the SMS gateway with a single query. If you send out several hundreds, thousands of hundreds of thousands the database option is the only valid choice.

Disadvantages of sending SMS using the HTTP SMS API

The biggest disadvantage of using the HTTP API is that you must be sure that the HTTP SMS service is available when you send your SMS. If you send an SMS at a moment when the SMS gateway is rebooted or when there is a temporary network failure, you request will not work. Your SMS can be lost. This issue does not affect the SQL to SMS solution.

Another disadvantage is the extra work required in keeping track of sent messages and delivered to network or delivered to handset reports. This is hard because these events happen later. The messages is delivered to the network a few seconds after you issue the HTTP request for submission, and it can take significantly longer for the SMS to reach the recipient handset (think of the recipient handset being switched off temporarily). The Ozeki HTTP api can be asked to notifiy your PHP script about these events, but it is more work to write the code to handle these events.

Where can I find setup instructions for sending SMS using HTTP?

The following page contains a video tutorial and detailed step by step instructions on how to setup SMS message on a PHP website with HTTP requests.

Summary

The document you have read is about how to send SMS messages from a website running on PHP with the help of the Ozeki SMS Gateway. This solution gives you the ability to decide if you want to use HTTP requests to pass SMS messages directly to the SMS gateway or to save your outgoing messages into a database and let the SMS gateway pick up the messages from there. If you have followed the steps above, now you can set up whichever option you choose based on the mentioned advantages and disadvantages.

You can jump into other articles on the Ozeki website, get the information we offer. Go on and read the next guide about how to send SMS from MySQL with PHP.

Download the Ozeki SMS Gateway now and set up the system in a few minutes!