Send SMS from PHP using HTTP

Ozeki NG SMS Gateway has a built in HTTP Client and a built in HTTP Server. This makes it possible to send and receive SMS messages using HTTP requests. In this chapter you can read about the possible configurations you can setup if you want to send and/or receive SMS messages using HTTP from a web based application, such as a PHP script.

Configuration #1 - Receive only

In this configuration we use the system for receiving only. If an SMS comes in it is forwarded to a PHP script in an HTTP request. To setup this configuration, you need to install the HTTP Client user in Ozeki NG SMS Gateway. The next step is to configure the URL of "PHP Script #1" in the "HTTP URL to be called if an SMS message arrives:" field of the "Incoming tab" of the Http Client user configuration form. "PHP Script #1" should return an empty response.

how an only receiver system works

Configuration #2 - Receive SMS and send a response immediately

In this configuration we use the system for receiving an SMS message and for sending a response SMS immediately after the message has been received. In this configuration you cannot send a message without receiving one first. To setup this configuration you need to install the HTTP Client user in Ozeki NG SMS Gateway. The next step is to configure the URL of "PHP Script #2" in the "HTTP URL to be called if an SMS message arrives:" field of the "Incoming tab" of the Http Client user configuration form. The "PHP Script #2" should return an HTTP response formatted according to the SMS response format specification. The content of the HTTP response will be sent as an SMS message, to the specified recipient. More information about this configuration can be found in the "Receive SMS on website" guide.

send a response immediately

Configuration #3 - Send an SMS message using HTTP polling

This configuration shows, how the software can be used to send messages asynchronously. Asynchronous sending means, that the PHP script can send a message when the outgoing message become available in the back end system. In this configuration the PHP script does not have to wait for an incoming message. Ozeki NG SMS Gateway will periodically download the output of the PHP script, and if the PHP script returns a response, it will be sent as an SMS message. Note that in case the mobile phone does not send an SMS message, yet the HTTP request is initiated by the Ozeki NG SMS Gateway system.

To configure this solution you need to install the HTTP Client user. On the HTTP Client user configuration form, you need to enable the "Download outgoing messages from the following URL: " checkbox, and you must put the URL of "PHP script #3" into the "Download outgoing messages from URL:" field in the "Outgoing" tab of the Http client user's configuration form. The PHP script should format the output according to the SMS response format specification.

sending an sms with http polling

Configuration #4 - Send an SMS message using client originated request

Configuration #4 is different from the previous ones, because it does not use the HTTP Client user. It uses the built in webserver of Ozeki NG SMS Gateway. To use the built in webserver, you need to setup an HTTP Server user! The HTTP server user can access the HTTP API of the built in webserver. The HTTP API is explained in detail on the following URL: HTTP SMS API specification. The use of this API is also explained in the "Send SMS from a website (PHP)" and the "How to send a VCard SMS to a cellphone from a PHP website"document.

sending an sms using a client originated request

More information