Building your own SMS Gateway would be a pretty challenging task. Using the API for an existing SMS Gateway to send and receive SMS messages is pretty easy to do. I have used Twilio and I was able to get it running quite quickly.
To integrate an sms solution with a gateway to your website you will need a php and a html scritps to create it. The html form will send the data of your messages to the php script, and that will forward it to the sms gateway. Use the following codes copied from the website you mentioned to create the two files you need.
Here is an example code for HTML form: