This is an async dockerized API-based sms gateway application written in PHP.
I've implemented two sms service providers api in this application, Ghasedak and Kavenegar.
For messaging and async implementation, I've used RabbitMq.
For containerization and infrastructure freedom, I've used Docker.
- Go to the root of the Pony Express directory.
- Open the
.envfile and set theLOCAL_APP_PORT,LOCAL_RABBITMQ_PORTandLOCAL_MYSQL_PORTrelated on your choice. (Note that the ports you are going to declare are empty.) - run:
docker-compose build - run:
docker-compose up -d
route: http://localhost:8000/api/sms/send
Note that 8000 is the value of LOCAL_APP_PORT environment variable in the .env file
Body | urlencoded
| Key | Value |
|---|---|
| number | 09120635002 |
| text | Hello from Pony Express! |
| provider | ghasedak |
Note:
You can omit the provider key in the body. If you do this, Ghasedak will be the default provider.
####Curl:
curl --location --request POST 'http://localhost:8000/api/sms/send' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'number=09120635002' \
--data-urlencode 'text=Hello From Pony Express!' \
--data-urlencode 'provider=ghasedak'
###Simple Reporting and Monitoring UI:
On the http://localhost:8000/ route you can fill the username and password with the admin and then use the querying and reporting UI.
Note:
In this page for number and text inputs you can think that you are querying in SQL with LIKE operator.
For example if you fill the number input with 0912063% you will receive the messages that start with 0912063
In the .env file you can set the api keys for sms service providers.
For example, you can declare the api key for ghasedak sms service provider with GHASEDAK_API_KEY environment variable.
Also, you can change the line numbers for providers depending on your needs in the .env file.
- Go the
src/pony/Providerspath and create a directory. - In the created folder, create a class with the name of sms service provider.
- The class that you defined must extend from the
AbstractProviderclass. - All you have to do in this class is implement a method with the following signature:
public static function send(string $number, string $text). Your functionality for a simple send according to your sms service provider must be implemented here. - The last thing you must do is that map your new sms service provider in the
src/pony/Providers/providers.php. This is a file that returns an associative array which maps the providers to their own classes.