Skip to content

Developer GatewaySupport

Jethro Carr edited this page Mar 20, 2015 · 1 revision

Developing SMS Gateways for SMStoXMPP

Introduction

SMStoXMPP was originally designed for coupling with Android software-based SMS gateways - by combining an old/cheap Android cellphone, SMS Gateway application on the phone and SMStoXMPP, one can have a fully functional gateway solution for very low budget.

The self-contained nature of Android devices makes it possible to leave different phones in different countries as remote gateways, to make it possible to chat with friends when overseas without needing to take the local SIM roaming.

However the design of SMStoXMPP allows for numerous different backends to be used and anyone with a basic understanding of PHP would be able to put together a new gateway module.

This page details how the gateway support works and how a new module can be written.

Contributing New Gateways

Please commit any new gateway modules back to the project by attached a patch to the issue tracker, or emailing to the lead developer.

Structure of a Gateway Module

SMStoXMPP supports multiple different gateways and allows the concurrent use of different types of gateways, by means of forking each gateway process.

Gateways are stored in app/include/gateways/ and are named the same as their label in the configuration.

A gateway called "example" would be app/include/gateways/example.php and would be defined in the app/config.ini file like so:

[mycoolexamplegateway]
gw_type		= example
gw_path		= auto
...

Gateways can support receiving messages in one of two different ways:

  1. Via a regular polling function in the gateway, as triggered by SMStoXMPP every loop.
  2. Via an incoming HTTP GET or POST to the listener.php page.

The latter requires that the calling application calls the page with the HTTP GET option of ?device=gatewayname in order to be able to determine which gateway to call. Once this happens, the gateway module's code is responsible for deciding how to process the incoming request.

Getting Started

To get started with writing a new gateway module, clone the existing app/include/gateways/template.php module and make the appropriate code changes to suit your requirements.

If an external code library is required to support your gateway, add it into app/include/external/.