Are you having to create an SMS gateway for your project or are you using an exisiting SMS Gateway.
Take a look at
This
This example is using an exisiting Gateway (which most will), so perhaps a look at an existing API is a good start, such as
ozekisms