This project was a quick experiment to show use case of webhooks using a LAMP stack (though we don't need MongoDb).
- Silex (You can use symphony or any other library)
- Webhook
- Ultrahook
It rings a bell sound whenever someone makes a payment on your site given you use stripe payment gateway or whenever someone makes a new commit to your project on github.
Note: Even if you're not using stripe or github, it should be fairly simple to use the this method to play bell with any platform having support for webhooks.
In such case, you have to find an alternative to Ultrahook by creating your own HTTP server that forwards the webhook requests. Beacuse Ultrahook only supports github and stripe domains only.
- Download Bell sound file (I used the following bell-ding-sound-effect) and change name of the file in play.sh (Currently it is bell.mp3)
- Ultrahook (To forward the webhook requests to local environment)
- Stripe or Github account
-
Install a package to play sound files from shell (we will use play. Alternatives: how-to-play-a-sound-from-terminal)
sudo apt install sox
And for playing special formats like mp3 you must install its libraries:sudo apt install libsox-fmt-mp3
If you want to use it with full libraries, you must install libsox-fmt-all package: sudo apt install libsox-fmt-all
-
Clone the repository in the root of your apache server (or any http server with php)
-
Give permission to your apache server user to use Audio
sudo usermod -aG audio www-data
www-data is the name of the apache user. To know this name in your case, you can use "whoami" in exec in Php. -
Set the webhook URL in stripe or github to the ultrahook url (or other if its your own server)
-
Start apache server
-
Start Ultrahook (No need to do anything if you're using custom server to forward webhook requests)
ultrahook stripe http://localhost/Notification-Bell/webhook